Questions tagged [smart-contract]

Everything smart contract related, either WASM or EVM based.

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

How to receive input for mocked ink_env::test::ChainExtension

I'm trying to write an off-chain test for an ink! smart-contract that uses chain extensions. The example showing how to mock an extension for tests is never using the supplied _input argument. The ...
user avatar
  • 1
3 votes
1 answer
20 views

Build Issues when implementing PSP22 token standard for ink! contract

I am trying to implement the PSP22 token standard but getting errors when building my contract. The errors are: #[brush::contract] | ^^^^^^^^^^^^^^^^^^ use of undeclared crate or module ...
user avatar
4 votes
0 answers
26 views

Is the WASM blob created from ink! contract always deterministic

The contract's source code is provided during the contract verification on a block explorer (or some other source verifier). The block explorer needs to compile that source and verify if the generated ...
user avatar
  • 41
0 votes
1 answer
27 views

Outdated contract-api documentation

Trying to follow these examples: https://polkadot.js.org/docs/api-contract/start/code#create-a-blueprint which fails with: createBlueprint is not a function Seems like the examples in the ...
user avatar
  • 173
1 vote
0 answers
30 views

What is the best way to make a cross contract call on Ink!

I found 2 ways to make cross contract calls on ink!. The first is in this link here where another contract is called directly, The second is in this link here where a reference(ref) is being used. I ...
user avatar
4 votes
0 answers
34 views

cargo-contract throws on a valid WS URl

Most recent version (v1.3.0) of cargo-contract does not parse a valid WS url: cargo +nightly contract upload --suri '//Alice' --url 'wss://ws-smartnet.test.azero.dev:443' ERROR: Rpc error: Networking ...
user avatar
  • 173
0 votes
1 answer
44 views

Make token/nft transfer within smart contract

I want to make token/nft transfer inside smart contracts. I saw some examples of token transfers and taking that reference, I tried to replicate something similar to that. here is the code. #![no_std] ...
user avatar
1 vote
1 answer
19 views

Non-uint256 TokenID for 721/1155 NFTs? (arbitrary var types)

I'm using an InkLang implementation for 721Light/1155 (undecided) For my purpose, the contract is offering domain-like NFTs. So an infinite amount of IDs, but a max balance of 1 for any ID. From what ...
user avatar
  • 11
0 votes
0 answers
31 views

Ink contract deployment out of gas

When deploying a smart contract on local-net, polkadot.js fails with: system.ExtrinsicFailed, contracts.OutOfGas This seems to be due to having the following enum in the contract storage: #[cfg_attr(...
user avatar
  • 187
1 vote
1 answer
62 views

Ink cannot derive SpreadLayout and SpreadAllocate for simple struct and enum

When developing Ink! smart contracts I found that SpreadLayout and SpreadAllocate cannot be derived for simple structs or enums that are members variables of the contract and I have to implement the ...
user avatar
  • 187
3 votes
1 answer
48 views

How to iterate over Mapping<K,V>?

I have a very basic question - ink! now has a Mapping struct for key-value pairs. It seems it does not implement the Iterator trait?
user avatar
  • 173
2 votes
1 answer
23 views

Is it feasible to modify the contracts pallet to integrate it into a non-substrate rust-based blockchain?

Is it feasible to modify the contracts pallet to integrate it into a non-substrate rust-based blockchain? Say one that runs on Tendermint.
user avatar
1 vote
1 answer
23 views

Are there any tools available for creating a mock version of a contract in JS/TS?

Currently, we use "live" versions of our contracts running on a substrate contracts node in our JavaScript tests. This makes them integration tests and difficult to include in simple GitHub ...
user avatar
  • 568
2 votes
2 answers
60 views

Panic in Ink! Smart Contracts

I want to find out how exactly "revert" works in ink! smart contracts: What happen if we panic!() in ink! contracts? IIRC we shouldn't use panic!() in runtime. Is there any difference ...
user avatar
1 vote
1 answer
31 views

Rust ink! Utc::now() from chrono libary returns : function or associated item not found in `chrono::Utc'

as the title suggests. I imported chrono 0.4 just like in the documentation Here And when i ever i call Utc::now() to get current UTC time, i get error that the function now() doesn't not exists. Here ...
user avatar
0 votes
1 answer
24 views

Standards for PSP34 thumbnail/image and resource url?

Are there some standard attributes to use for URLs for images and other meta-information on PSP-34? I see that RMRK has that but it is only on Kusama.
user avatar
1 vote
0 answers
46 views

Contract call returns error "Found input with 28 bits, expected 8". Polkadot.js and ink contracts

as the title suggest, Im trying to call PSP22 token contract and read balanceOf() function, but i get error that im passing a too big of a input (27 instead of 8) Im trying to invoke balanceOf() PSP22 ...
user avatar
1 vote
1 answer
28 views

Ink! ink_env::debug_println! does not work if message is payable

Adding #[ink(payable)] to a #[ink(message)] prevents ink_env::debug_println! messages to be logged in console when executing the smart contract call. Any additional config needed in this case to have ...
user avatar
  • 187
1 vote
1 answer
53 views

Can we mint/burn Statemint assets on other parachains?

My goal is to create an interoperable NFT collection in the Polkadot native ecosystem and allow its holders to interact with it on a parachain's smart contract. In that smart contract, the holder can ...
user avatar
  • 13
1 vote
1 answer
48 views

Can we write bridge smart contract using ink?

I was reading about ink smart contracts and was curious is it possible to make bridge using ink, as there is already parity-common-bridges present. It would be very helpful if someone knows about this ...
user avatar
0 votes
1 answer
27 views

Parsing JSON in ink based Smart Contracts

Currently I am developing a Fat Contract (Native to Phala Network) that also supports Ink Based Smart Contracts to be written within the Fat Contracts which is what my example is doing. To describe ...
user avatar
  • 21
1 vote
1 answer
21 views

How to retrieve dynamic type size data from chain extension in ink? [duplicate]

my example looks like this : #[ink(extension = 1111] fn asset_name(asset_id: u32) -> Result<[u8], PalletAssetErr> or this fn asset_name(asset_id: u32) -> Result<[u8], PalletAssetErr>...
user avatar
  • 31
1 vote
1 answer
35 views

Fetch storage data and convert it to primitive types with subxt

I want to get the bool value from the flipper contract. I use Rust and subxt. But I cannot convert it to a primitive type. let value: bool = api .metadata() .pallet("...
user avatar
2 votes
3 answers
83 views

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

I am querying extrinsic data and I am able to fetch gasLimit and gasPrice out of Extrinsic.method.args. But how do I fetch the amount of gas used from an extrinsic?
user avatar
3 votes
1 answer
31 views

How to enable chain extensions?

I have a chain extension implemented on substrate-contracts-node and in my ink! smart contract according to this tutorial. When I try to instantiate my contract on a local contracts-ui I get the ...
user avatar
  • 2,870
1 vote
1 answer
17 views

How do I get the code hash of a smart contract using Polkadot{.js} API?

I know polkadot{.js} has an API to access contract storage here: https://polkadot.js.org/docs/substrate/storage#contracts How do I get the code hash via the account?
user avatar
  • 2,870
4 votes
1 answer
53 views

How to call runtime functions from a contract

A chain_extension is one way to call into the runtime from a smart contract on the contracts pallet. What other methods exist, and why might you use them instead of the extension pattern?
user avatar
2 votes
1 answer
34 views

How to return error from chain extension?

I saw how to handle error from chain extension on smart contract side https://paritytech.github.io/ink-docs/macros-attributes/chain-extension#error-code But I can't find example and can't understand ...
user avatar
  • 31
4 votes
1 answer
52 views

How to benchmark a chain extension?

I would like to know the recommended way to benchmark a chain extension, and then how to charge the calculated weight. According to this document, we need to write benchmarks.
user avatar
2 votes
1 answer
25 views

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

I've seen instant seal mentioned as a way to get transactions sealed by the substrate node upon receipt. I also know that moonbeam have this in their node. Is there a substrate node that includes ...
user avatar
  • 568
3 votes
1 answer
48 views

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

When we have an Ink! smart contract code calling a chain extension, how do we receive this information from within the chain extension: The calling smart contract address/ID The original caller of ...
user avatar
  • 143
8 votes
3 answers
91 views

How to have a mapping in a custom structure inside an ink! contract?

I'm a newbie with rust and substrate. I'm currently trying to build a PSP34 compatible smart contract (NFT) for documents. In this contract, I'd like to have the following structure: #[derive(Default, ...
user avatar
7 votes
2 answers
69 views

Wasm interpreter in pallet-contracts

I have a question about how pallet-contracts interprets a Wasm contract. Are the following assumptions correct? pallet-contracts interprets contracts through the simple wasmi interpreter gas metering ...
user avatar
0 votes
0 answers
66 views

Unable to get ecdsa_recover to return the proper pub_key in an ink! contract [duplicate]

I'm using sp_core::ecdsa::Pair to create a pair from the seed, and sign a message hash. But, ecdsa_recover isn't returning the correct pub_key back. I have pushed my code here. I have also added a ...
user avatar
  • 351
2 votes
2 answers
71 views

How to get AccountId from compressed public key in an ink! contract?

I'm trying to do the signature verification in an ink! contract. I'm using ink_env::ecdsa_recover for this purpose. It is returning Compressed Public Key of type [u8; 33]. I have the AccountId of the ...
user avatar
  • 351
9 votes
1 answer
48 views

Incorrect display name for smart contracts numeric return types

When I deploy an ERC20 on Polkadot JS Apps, i can see that the return type of total_supply is u128, however according to the contract metadata it should display Balance. Noticed also for ERC1155 ...
user avatar
6 votes
1 answer
61 views

Performance of same logic with a contract using pallet-contracts vs. a native pallet (excluding metering)

I'm wondering what is current state of the art of Substrate's pallet-contracts performance as compared to the same functional implementation as a pallet. I acknowledge that different logic can have ...
user avatar
  • 315
5 votes
2 answers
87 views

How do I test a chain extension used in the runtime?

I am aware of this example that shows how to create a mock chain extension and test that. However, I do not know how to test the chain extension that is used by the runtime and calling functions from ...
user avatar
3 votes
3 answers
74 views

How to resolve duplicate lang item error?

I couldn't compile ink_env when doing cargo contract build. Tried cargo update by referencing this other [post] (error: duplicate lang item in crate `std` (which `arrayvec` depends on): `panic_impl`). ...
user avatar
6 votes
3 answers
81 views

Why is it a bad idea to use String in an ink! smart contract?

I've heard that it is a bad idea to use Rust's String type in an ink! smart contract. Why is this so? And what is your recommendation to use instead for typical use cases of String ‒ so parsing input ...
user avatar
2 votes
1 answer
27 views

What is "value" and "storageDepositLimit" in contract call?

After I called an contract, this is the extrinsic I found in the block: What do these fields mean: value, storageDepositLimit ?
user avatar
5 votes
1 answer
67 views

How to inform polkadot.js wallet to approve erc20-type token transfer? [closed]

I am developing smart contract that can stake erc20-type token, and testing it on shibuya testnet. But i have some problems. My staking contract have to request erc20-type token contract to approve ...
user avatar
2 votes
1 answer
41 views

Chain Extension func_id enumeration is resulting in ContractTrapped for func ids greater than 1

I'm encountering an issue where a contract is only able to called functions in my chain extension if they are enumerated with function ids 0 and 1. My chain extension has four functions, lets say ...
user avatar
  • 333
1 vote
1 answer
41 views

Confilct packages Error in ink! smart contract

I'm trying to build some ink! contract code (this one) but I got this error: error: There are multiple `parity-scale-codec` packages in your project, and the specification `parity-scale-codec` is ...
user avatar
6 votes
2 answers
114 views

cross contract call failure when using different salt to instantiate contract

I tried deployed two ink-compatible solidity smart contract using solang as the compiler. When trying to play around cross contract calls, I've stumbled upon the below failure: Prerequisite: compile ...
user avatar
0 votes
1 answer
25 views

Extrinsic Failed - Contract code rejected while implementing upgradable contract

I was following this example of ink! upgradable smart contract. After I uploaded the upgradable_contract.contract (Step 4 in the link), I got the following error: How can I fix it?
user avatar
0 votes
1 answer
33 views

PolkadotJS API React

When using the PolkadotJS API to query an ink! erc20 smart contract balanceOf() function from inside of react it returns some strange values. For example if i try this from a node script balanceOf....
user avatar
  • 1
10 votes
2 answers
129 views

How to upgrade a smart contract logic?

I deployed a smart contract to a substrate chain. How can I upgrade the smart contract's logic to a newer version? Edit: I'm using ink! and deployed on Shibuya (Astar testnet)
user avatar
2 votes
2 answers
79 views

How to decode smart contract call and event data?

I want to decode the contract call data and event data saved in a block. How can I do that?
user avatar
2 votes
1 answer
37 views

NewContractNotFunded error using contracts pallet with version 4.0.0-dev

I'm running into an issue where I cannot deploy contracts to my chain, any help is appreciated. I'm using the same setup as: https://github.com/paritytech/substrate/blob/...
user avatar
  • 333