25

怎样拉起 MetaMask, 授权某个合约使用我的钱包 | 登链社区 | 技术问答

 3 years ago
source link: https://learnblockchain.cn/question/1939
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
怎样拉起 MetaMask, 授权某个合约使用我的钱包

5 怎样拉起 MetaMask, 授权某个合约使用我的钱包

怎么给某个合约地址授权?

image.png

我是这么写的,但是点击按钮,没有反应:

// before all, request privilege, first
  const handleReqPri = () => {
    const w = new Web3(ether);
    const wethAdr = getWETHContract(w);
    const strBlindAuctionAdr = getBlindAuctionAddress();
    wethAdr.methods
      .approve(strBlindAuctionAdr, new BigNumber("100000000000000000"))
      .call()
      .then(function (result: any) {
        console.log("handleReqPri ===>", result);
      })
      .catch((_error: any) => {
        // If the request fails, the Promise will reject with an error.
        console.error("privilege error ? : ", _error);
      });
  };

image.png

最佳答案 14小时前

使用 call 调用不会发起交易。
这里应该是 send( 把 call 修改为 send )。

什么时候用 call, 什么时候用 send?

  • 14小时前
Tiny熊 - 布道者
擅长:智能合约,以太坊 | 采纳率 42% | 回答于 18小时前

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK