BSC 测试网 web3.js调用合约的一个需要gas费的函数 报错

BSC 测试网 web3.js调用合约的一个需要gas费的函数 报错be5ddd7eb10792ce221bc151b6d260d.png

前端代码如下:

const web3 = new Web3("https://data-seed-prebsc-2-s2.binance.org:8545");
const encodeABI = this.WalletInfo.contract.methods
                        .active(web3.utils.toHex(this.WalletInfo.inviteCode), web3.utils.toHex(this.WalletInfo.address)) // 参数
                        .encodeABI();

                    const options = {
                        gas: "4926450",
                        gasPrice: "30000000000",
                        to: this.WalletInfo.tokens[0].contract, // 系统合约地址
                        data: encodeABI,
                    };
                    web3.eth.accounts.signTransaction(options, 私钥).then(res=>{
                        // 发送交易
                        web3.eth.sendSignedTransaction(res.rawTransaction).on('transactionHash', function(hash){
                               // console.log("发送成功,获取交易hash:",hash)
                           }).on('receipt', function(receipt){
                               // console.log("链上结果返回,返回数据:",receipt)
                           }).on('confirmation', function(confirmationNumber, receipt){
                               console.log("链上confirmation结果返回,确认数:",confirmationNumber)
                               console.log("链上confirmation结果返回,返回数据:",receipt)
                           }).on('error', function(error){
                               console.error(error)
                           });
                    })
                }

哪位大牛能帮我解决一下嘛?万分感谢!!!

请先 登录 后评论

2 个回答

Tiny熊 - 布道者
  擅长:智能合约,以太坊
请先 登录 后评论
pan
请先 登录 后评论
  • 2 关注
  • 0 收藏,2301 浏览
  • Hthursday 提出于 2022-01-20 16:16

相似问题