在确认浏览器或Chrome扩展名交易之前,如何获得Web3合同地址?

发布于 2025-02-07 22:41:33 字数 120 浏览 2 评论 0原文

假设我想购买NFT,我的Metamask弹出窗口打开,要求我确认交易。在那里,您可以看到合同地址...但是如何使用浏览器中的JavaScript或扩展名中的JavaScript访问此合同地址(仅检索该值,不要更改:) :))?

Let's say I want to buy an NFT and my Metamask popup opens asking me to confirm the transaction. There you can see the contract address... but how can I access this contract address (just retrieve the value, not change it :) ) programmatically using javascript in the browser or an extension?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡忘如思 2025-02-14 22:41:33

嘿,要在控制台上获取合同地址,只需在.sol文件中包含此代码,并更新代码的ABI。

    function get() view public returns(address ){
        return address(this);
    }

在前端,与您的智能合约施加了作用,并将结果在控制台中包含在您的index.js文件中

              contract.methods.get().call().then(function (resp){
               console.log(resp);
              });

Hey for getting the contract address on your console just include this code in the .sol file and also update the abi of the code .

    function get() view public returns(address ){
        return address(this);
    }

And in the frontend to intract with your smart contract and for getting the result in the console include this in your index.js file

              contract.methods.get().call().then(function (resp){
               console.log(resp);
              });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文