如何与已经部署的智能合约连接?

发布于 2025-02-07 14:07:59 字数 295 浏览 1 评论 0原文

我是一个崭露头角的区块链开发人员,我一直在用来深入研究事物,因为这是我最喜欢的语言。

我现在处于僵局,希望我能得到一些帮助。

与GO一起使用智能合约时,我看到的几乎所有教程都涉及使用Geth将固体源代码编译为其ABI和二进制表单,然后生成一个.go文件,并具有对部署和其他操作的合同的绑定。

当使用我自己的创建合同时,这很好,但是如何与已经部署的第三方合同(例如Cryptokitties)进行交流?基本上,在我可能无法访问合同源代码来生成绑定的情况下。

通过牢固,我只需要定义所需合同的界面,但是Go似乎并不那么简单。

I'm a budding blockchain dev, and I've been using Go to dive into things as that's the language I'm most comfortable with.

I've at an impasse now, and hope I can get some help.

Pretty much all the tutorials I've seen on working with smart contracts with Go involve using geth to compile the Solidity source code to its ABI and binary forms then generating a .go file with bindings to the contract for deployment and other actions.

This is fine when working with my own created contracts, but how would I go around interfacing with already deployed third-party contracts such as Cryptokitties for instance? Basically, in the cases where I may not have the luxury of having access to the contract source code to generate bindings.

Going through the Cryptozombies course, with Solidity I just had to define the interfaces of the desired contract, but Go doesn't seem to be as straightforward.

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

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

发布评论

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

评论(1

追我者格杀勿论 2025-02-14 14:07:59

您可以手动将ABI文件从etherscan到本地工作区保存,以生成绑定。

例如,您可以从此

注意:

  • 坚固性是唯一不需要ABI的语言,因为它是EVM(以太坊虚拟机)上合同开发的母语。
  • 您也可以使用 etherscan api 以编程方式检索ABI。但是我认为在大多数情况下我们不需要走那么远。

阅读更多: https://geth.ethereum.org/docs/docs/docs/dapp/native/native/native/native-binding

You could manually save the ABI files from Etherscan to your local workspace to generate the binding.

For example, you can copy ABI from this CryptoKitties contract. As long as the contracts are verified, you can always get the ABIs.

Note:

  • Solidity is the only language that doesn't need ABI because it is the native language of the contract development on the EVM (Ethereum Virtual Machine).
  • You could also use Etherscan API to programmatically retrieve the ABI. But I don't think we need to go that far in most of the cases.

Read more: https://geth.ethereum.org/docs/dapp/native-bindings

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