Let's say I have a contract in solidity
:
pragma solidity 0.8.8;
contract MyContract{
function getFive() public pure returns (uint256){
return 5;
}
}
Could I import, inhert, etc in vyper
? Or do something with it's ABI to import into vyper?
Ie in vyper:
from MyContract import getFive
Additional:
- Would the best thing to do be to rewrite contracts into vyper interfaces if I just wanted to interact with a contract?
- Is there some way to grab the solidity bytecode of a function and drop it into vyper? (Or even the vyper bytecode…)
Best Answer
vyper supports importing interfaces from JSON ABI files. You can convert a vyper contract to a JSON ABI interface file with
vyper -f abi foo.vy
, and you can convert a solidity contract to a JSON ABI interface file withsolc --abi foo.sol
. In the latest version of vyper, v0.3.3, you would importfoo.json
using the following syntax: