Reputation: 27
i have the abi json file for a contract and i want to use its functions in my smart contract. is there any way to do it?
for example i have a contractA.sol and contractB.jsonn in my contractA i want to call a function fncA in the contractB, but contractB is elready deployed and i just have its abi file. i imported the json file to my contract but then i don't know how to fetch its functions and use them.
import '../abis/contractB.json'
contract contractA {
.
.
.
// i want to use funcA from contractB contract here.
.
.
.
}
Upvotes: 0
Views: 891
Reputation: 857
Unfortunately solidity doesn't supports using json ABIs as interface.
You can use some tools like this https://gnidan.github.io/abi-to-sol/ to generate the interface, then copy it into a 'IContractB.sol` file, which can be imported in your 'ContractA.sol'.
Upvotes: 1
Reputation: 1
yes you can do it in a very few steps. just use the abi of a particular function and paste it in a new abi of a smart contract on which your are currently working and call that method just using web3.
please reply if you have any queries.
Upvotes: 0