Skip to main content
16 votes
Accepted

Wasm interpreter in pallet-contracts

All your assumptions are correct. And yes we have a double layer of execution right now. There exists an API that allows us to have the execution engine within the the client (native code) which would ...
Alexander Theißen's user avatar
8 votes
Accepted

error[E0158] when testing default contract from flipper

cargo-contract latest release currently is v1.5.0 which was released on 15th August 2022. So I used rust nightly build of that day and it worked. I have ran the following commands and I am able to ...
Rahul Soshte's user avatar
7 votes
Accepted

Are there any publicly available test nets that run pallet contracts?

There is a rococo parachain which is maintained by Parity. Instructions for its faucet can be found along with its source code.
Alexander Theißen's user avatar
7 votes
Accepted

Correct way to use dynamic sized types in chain extension

In order to read memory from a contract you should check out the different functions on the Environment type. As Green Baneling already pointed out correctly you should use SCALE in order to encode ...
Alexander Theißen's user avatar
6 votes
Accepted

How can I call my contract methods inside a pallet?

It's pretty straightforward to call a contract from a pallet. I'm going to assume you're calling an ink! contract with the following message for the purposes of this answer. #[ink(message)] pub fn ...
HCastano's user avatar
  • 1,071
5 votes

Wasm interpreter in pallet-contracts

Overall your assumptions are correct. WASM Smart Contracts are currently interpreted by the wasmi Interpreter. There exists indeed considerations to switch to the wasmer compiler/runtime. AFAIK those ...
Achim's user avatar
  • 575
5 votes
Accepted

Is there a substrate node that contains pallet-contracts and uses instant seal consensus?

The substrate contracts node already uses instant seal. Just update to the latest version.
Alexander Theißen's user avatar
5 votes
Accepted

Gas costs of performing cross-contract calls

The overhead is significant. This is because for cross-contract calls the pallet-contracts needs to: Load the callee contract code from storage. Compile the code (using wasmi). Set up a new sandboxed ...
cmichi's user avatar
  • 2,800
5 votes
Accepted

Error: no matching package named 'pallet-contracts-rpc' found

This was removed in #12358, You no longer need to add the RPCs. Have a look at this as an example. Porting Guide The high level contracts API in polkadot.js already uses state_call so upgrading to ...
Nuke's user avatar
  • 1,842
5 votes

How can I generate a random seed now that self.env.random() is removed in ink?

Unfortunately there is no way to generate randomness using ink! The only options I see: Creating an VRF oracle contract that will generate randomness(DIA is working on it for Astar) On runtime level ...
P.Ossun's user avatar
  • 1,219
5 votes
Accepted

Caching of smart contract storage reads

will the 123 cell be read twice, or is it cached on the first read? It will be read twice. At the moment the Lazy type is just a thin wrapper around ink::get_contract_storage. So arguably Lazy here ...
Andrew Jones's user avatar
5 votes
Accepted

Get contract address from instantiated ContractRef

You can use to_account_id method to obtain address of instantiated smart contract. use ink::ToAccountId; let contract_address = multisig.to_account_id();
Bobo K.'s user avatar
  • 386
4 votes

How to call runtime functions from a contract

With an ink! smart contract, you are interacting with the runtime via the contracts-pallet and it's default defined API. If you want to extend the contracts-pallet API, the recommended ink! way of ...
Bruno's user avatar
  • 8,315
4 votes
Accepted

How to do contract RPC call?

Looks like your gasLimit is too low. Increase gas limit or simply set it to -1 which will use max. gas available.
Bobo K.'s user avatar
  • 386
4 votes
Accepted

How to inherit Ink! traits/contracts

It is not inheritance, it is called supertrait. It is a bound for the trait that if someone implements your CustomErc20, he also should implement the Erc20 trait. ink! right now doesn't support it(...
Green Baneling's user avatar
4 votes
Accepted

Can you query the state of a contract at a given block number?

Similar to other RPCs you can pass a block hash to the contracts_getStorage RPC (using the at parameter) in order to query the state at a historical block: It is not possible to do that on-chain (i.e ...
Alexander Theißen's user avatar
4 votes
Accepted

How to sign an extrinsic as a smart contract in the browser?

There is no (known) secret key for a contract's account id. This is kind of the point of contracts: Their actions are governed by code rather than by an external force that can provide a signature. ...
Alexander Theißen's user avatar
4 votes
Accepted

method not found" and "associated item not found" errors in a Substrate pallet function?

what version of the template / pallet-contracts are you using? --> /home/kianoush/projects/music-chain/frame/dex/src/lib.rs:323:36 323 | pallet_contracts::Pallet::<T>::...
Pierre's user avatar
  • 206
4 votes

Smart Contract blockspace allocation in Hybrid Chains

I looked into this a little bit. It looks like there is nothing built in at the moment. In frame there is one signed extension CheckedWeight that make sure that the weight for a specific DispatchClass ...
Pierre's user avatar
  • 206
4 votes

Incompatibility between subxt_signer and subxt

I found the solution to the problem. In my case, I needed to make changes to Cargo.toml. subxt-signer = { version = "0.31.0", features = ["subxt"]} I had to add features = ["...
Haider's user avatar
  • 71
3 votes
Accepted

Instantiating and Calling a contract using the Contracts Pallet

Question 1 Yes. The code is just the contents of the wasm file as emitted by the compiler. Question 2 pallet-contracts doesn't concern itself with the data. It just passes it down to the contract as-...
Alexander Theißen's user avatar
3 votes

How do I find the gas consumed by a contracts extrinsic?

Gas and weight are one and the same concept when it comes to pallet-contracts. We merely kept the name gas for historic reasons. The gas limit you supply to the contracts.call extrinsic directly ...
Alexander Theißen's user avatar
3 votes
Accepted

How to access environmental information about a contract from within a chain extension?

These environmental information is available to the ChainExtension through the Environment::ext() function. An instance of Environment is passed to ChainExtension::call() as a parameter. The ext() ...
Alexander Theißen's user avatar
3 votes
Accepted

Is it possible call wasm from evm smart contract on substrate chain?

It is be possible through Astar Network xvm_pallet, interaction between WASAM and EVM Contract. You can go through this article and there is also video for this.
go11li's user avatar
  • 1,241
3 votes
Accepted

unable to upload ink! contract in polkadot-JS

The current version of substrate supports a new version of "weights", whereby it is no longer just the execution time (a.k.a "gas") but also accounts for the "proof size" ...
Andrew Jones's user avatar
3 votes
Accepted

How to return uint256 datatype from ink! wasm contract? How to make compatibility with IERC20?

The best way is to use ethnum crate: https://crates.io/crates/ethnum Code example: #[ink(message] pub fn balance(&self, account : AccountId) -> [u128; 2] { let balance_u128 : u128 = self....
rust.dev's user avatar
  • 519
3 votes

What are the fees associated with ink! contract deployment?

Your assumptions you made in #1 to #6 are all correct. Now to your questions: This is the storage deposit for storing the code. In contrast to the deposit for the contract which is using said code (...
Alexander Theißen's user avatar
3 votes
Accepted

Can I deploy an old ink! v3.x contract on the latest version of substrate/polkadot (pallet-contracts >= polkadot-v0.9.37)?

You can deploy old ink! contracts to newer versions of pallet-contracts. The pallet is backwards compatible. Note that you will have to use a cargo-contract version from before 2.0: cargo install ...
cmichi's user avatar
  • 2,800
3 votes

How to sign an extrinsic as a smart contract in the browser?

The contract's address (i.e. AccountId) is derived through an AddressGenerator in pallet-contracts. This AddressGenerator is configurable. At the time of writing this, the default is here: hash("...
cmichi's user avatar
  • 2,800
3 votes

contract pallet installation issues

I think you mean the tutorial where pallet-contracts was added to the substrate-node-template. This tutorial is indeed removed. You can use substrate-contracts-node where you have a node-template with ...
Daan van der Plas's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible