简体   繁体   English

如何使用最新的 polkadot-js 和基板合约节点查询合约信息?

[英]How can I query contract info with the latest polkadot-js and substrate contracts node?

I've been unable to query my existing contract recently due to Unable to create Enum via index 128, in Alive, Tombstone when using api.query.contracts.contractInfoOf .由于使用api.query.contracts.contractInfoOfUnable to create Enum via index 128, in Alive, Tombstone我最近无法查询我现有的合同。 I get this error both on the command line and in the polkadot-js apps explorer.我在命令行和 polkadot-js 应用程序资源管理器中都收到此错误。

These are the steps I took:这些是我采取的步骤:

  1. Deploy a contract with a salt使用salt部署合约
  2. Retrieve the contract deployedAddress检索合约deployedAddress
  3. Use contractInfoOf使用contractInfoOf
  4. const contractInfo = await api.query.contracts.contractInfoOf(deployedAddress);

I've tried downgrading ink!我试过降级ink! to 3.0-rc5 , 3.0-rc4 , 3.0-rc3 and then compiling but it doesn't seem to make any difference.3.0-rc53.0-rc43.0-rc3然后编译但它似乎没有任何区别。 Whenever my contract is built it references rc6 at the top:每当我的合约建立时,它都会在顶部引用rc6

{"metadataVersion":"0.1.0","source":{"hash":"0x...","language":"ink! 3.0.0-rc6","compiler":"rustc 1.58.0-nightly",

Which suggests its ignoring my .toml and using rc6 to compile the contract.这表明其无视我的.toml并使用rc6编译合同。

I changed my cargo-contract version to 0.14 but that causes polkadot-js to fail at reading the contract abi.我将我的cargo-contract版本更改为0.14但这导致 polkadot-js 无法读取合同 abi。

I've tried using the substrate-contracts-node using the latest commit from master and also using the v0.1.0 release.我已经尝试使用来自 master 的最新提交并使用v0.1.0版本使用基板合同节点 Same error in both cases.在这两种情况下相同的错误。

> rustup info

stable-x86_64-unknown-linux-gnu (default)
rustc 1.56.1 (59eed8a2a 2021-11-01)

There are more details in an issue on polkadot-js . polkadot-js 上问题中有更多详细信息。

Any pointers on how to get a working setup would be very helpful!关于如何获得工作设置的任何指示都会非常有帮助!

The problem here was substrate-contracts-node using an old version of the metadata .这里的问题是使用 旧版本元数据的substrate-contracts-node

I was able to check out the repo before the metadata merge was reverted and build locally ( cargo build ).我能够在元数据合并被恢复并在本地构建( cargo build )之前检查存储库。

So checkout 8d91b8e to get it the node to work with versions 7.7.1 and 6.6.1 of polkadot-js packages.因此,请检查8d91b8e以使其成为与 polkadot-js 包的7.7.16.6.1版一起使用的节点。

> git checkout 8d91b8e578065a7c06433cbd41ac059bf478a0bd
> cargo build
> ./target/debug/substrate-contracts-node --dev --tmp --version
substrate-contracts-node 0.1.0-8d91b8e-x86_64-linux-gnu

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM