如何从角度签署智能合约交易

问题描述

我正在尝试从 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...