问题描述
我正在尝试从 Angular 应用程序执行签名事务。
我正在使用这个 ethers 包来初始化智能合约的实例。这里我要为函数签名---method1(string,unit256,unit256).
import abi from "ethereumjs-abi";
import {toBuffer} from "ethereumjs-util";
import { ethers } from 'ethers';
instance = new ethers.Contract(ADDRESS,ABI,provider.getSigner());
functionSignature = await instance.method1("abc",123,456).encodedABI(); //Here it fails,saying encodedABI is not a function. But same line works fine on nodejs.
let messagetoSign = this.constructTransactionMessage(nonce,chainId,functionSignature,contractAddress);
let hex = "0x" + messagetoSign.toString("hex");
let signature = await provider.signTransaction(hex); // I don't kNow is it right or not.
console.log(signature); //Final step
async constructTransactionMessage(nonce,contractAddress) {
return abi.soliditySHA3(
["uint256","address","uint256","bytes"],[nonce,contractAddress,toBuffer(functionSignature)]
);
}
我在 functionSignature 处收到错误,说 encodeABI 不是函数。
需要帮助。非常感谢!!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)