0

我想与我的智能合约交互以使用它们的功能。我正在使用该ethereum-react-native-boilerplate示例,并且正在尝试使用该useWeb3ExecuteFunction钩子执行智能合约功能。我运行这个示例并且它工作正常但是当我尝试与智能合约交互时react-moralis它不起作用并且只重定向到元掩码而不调用智能合约的函数。下面的代码在按钮单击时调用以调用智能合约功能。

 const ops = {
        contractAddress: "0x878......",
        functionName: "add_data",
        abi: [{"inputs": [{"internalType": "uint256","name": "amount","type": "uint256"},{"internalType": "uint256","name": "total_user","type": "uint256"},{"internalType": "address","name": "token","type": "address"},{"internalType": "string","name": "_value","type": "string"},{"internalType": "string","name": "symbol","type": "string"}],"name": "add_data","outputs": [],"stateMutability": "nonpayable","type": "function"}],
        params: {
          amount: 123333,
          total_user: 6,
          token: "0x34EE........",
          _value: "ABC Coin",
          symbol: "ABC",
        },
      };

      await contractProcessor.fetch({
        params: ops,
        onSuccess: () => {
          console.log("Approval Received");


        },
        onError: (error) => {
   
        },
      });

我遵循了 react-moralis 的官方文档 https://github.com/MoralisWeb3/react-moralis#useweb3executefunction

4

1 回答 1

0

使用 Moralis npm 模块包含用于 React Native 环境。

  • npm i moralis
  • const Moralis = require('moralis');
于 2022-02-19T14:37:17.597 回答