0

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?

ecode
  • 11
  • 3

1 Answers1

1

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);
}
ecode
  • 11
  • 3