Does useDApp support multiple contract call?

177 Views Asked by At

I am building a NFT marketplace using useDApp. To interact with the smart contract, I call function1 asynchronously by declaring

const { send, state } = useContractFunction(contract1, 'function1');.

The question is, how can I call function2 from contract2 without redeclaring send?

1

There are 1 best solutions below

0
ecode On BEST ANSWER

Issue got fixed, seems the send const in useContractFunction can only be used once in each class. A solution is to replace the function by

const { library } = useEthers();

const contract1 = new Contract(address1, abi1, library.getSigner());
const contract2 = new Contract(address2, abi2, library.getSigner());

async function execute() {
    await contract1.function1(params);
    await contract2.function2(params);
}