Questions tagged [smart-contract]

Everything smart contract related, either WASM or EVM based.

Filter by
Sorted by
Tagged with
0 votes
1 answer
68 views

unable to map abi string to array to object with known keys source, contract

I am trying to use the ContractPromise from @polkadot/api-contract to interact with a published smart contract on the moonriver network but when I try and create a new ContractPromise object I get the ...
cooper jones's user avatar
2 votes
1 answer
144 views

How to get contract's code owner

Can the information about the owner of the actual contract code blob (the account that deployed the code) be accessed from the contract environment?
fbielejec's user avatar
  • 331
3 votes
1 answer
73 views

Getting ink! contract metadata from the chain

I am playing around with ink! and invoking contract pallets. After uploading the contract to the chain from the polkadot extension, I get a JSON file back describing the metadata for the contract, ...
georgiosd's user avatar
  • 277
2 votes
2 answers
97 views

How to receive multiple parameters of different types in chain extension

As ink chain-extension example https://github.com/paritytech/ink/blob/master/examples/rand-extension/runtime/chain-extension-example.rs#L32 . It show how to receive one param. But if I want receive ...
莫海江's user avatar
0 votes
1 answer
36 views

How to run multiple Integration tests at once in Redspot Ink!

I am currently writing integration tests for my contracts using redspot, I can't seem to run all my integration tests at once, I can only run integration test by using the keyword it.only. Anytime I ...
dharjeezy's user avatar
  • 419
0 votes
1 answer
64 views

How to Send Additional Text Payload to Contract?

I need to send a string of a digit and a letter like "2F" to a contract deployed on a running contracts node. This payload is to be processed in the contract then. How can I include ...
CREESTL's user avatar
  • 474
3 votes
1 answer
201 views

How can I determine the native Balance of an Account/Address in Ink!

One can know the contract's native balance by using ink_env::balance() But, How can one know the native balance of a particular address/account in ink? For example, knowing the native balance of Alice,...
dharjeezy's user avatar
  • 419
2 votes
2 answers
285 views

Manipulate block timestamp for ink! integration tests?

I'm using redspot for integration tests. I have some contracts features involving with block timestamp. How can I manipulate the block timestamp in substrate-contracts-node?
Daniel Lam's user avatar
4 votes
3 answers
240 views

Are there blockchains based on substrates that use smart contracts and are on mainnet?

I'd like to know if there's a chain that smart contract is being in mainnet use of it.
Mehdi Raash's user avatar
3 votes
3 answers
325 views

cargo contract throws error about supplied arguments in ` #[ink(constructor)]` for version 3.0.1

In my smart contract, all the ink dependencies are set to =3.0.1 because of this issue: Cargo contract 3.0.1 When I tried to execute the cargo contract build or even cargo +nightly contract build to ...
Jitterbug's user avatar
  • 219
5 votes
1 answer
112 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 ...
ebma's user avatar
  • 53
3 votes
1 answer
95 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 ...
dharjeezy's user avatar
  • 419
7 votes
1 answer
128 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 ...
Maario's user avatar
  • 659
1 vote
1 answer
83 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 ...
fbielejec's user avatar
  • 331
4 votes
1 answer
263 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 ...
dharjeezy's user avatar
  • 419
2 votes
1 answer
150 views

Instantiating and Calling a contract using the Contracts Pallet

I find myself needing to do two things with the Contracts pallet, which each raise a question: I want to call the instantiate_with_code extrinsic from another Rust function. What is the correct way ...
jpataylor's user avatar
  • 321
4 votes
1 answer
121 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 ...
fbielejec's user avatar
  • 331
1 vote
1 answer
231 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] ...
pramitgaha's user avatar
1 vote
1 answer
34 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 ...
fig's user avatar
  • 11
0 votes
1 answer
163 views

Ink contract deployment out of gas [duplicate]

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(...
mastro's user avatar
  • 217
3 votes
1 answer
301 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 ...
mastro's user avatar
  • 217
6 votes
2 answers
206 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?
fbielejec's user avatar
  • 331
2 votes
1 answer
27 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.
Paul DeLucia's user avatar
1 vote
2 answers
54 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 ...
forgetso's user avatar
  • 1,462
3 votes
2 answers
485 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 ...
Daniel Lam's user avatar
2 votes
1 answer
177 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 ...
yonatan hornstein's user avatar
1 vote
1 answer
101 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.
user3384741's user avatar
3 votes
1 answer
148 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 ...
yonatan hornstein's user avatar
1 vote
1 answer
114 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 ...
mastro's user avatar
  • 217
2 votes
1 answer
158 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 ...
NoH's user avatar
  • 23
2 votes
1 answer
95 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 ...
Karanvir Singh's user avatar
0 votes
3 answers
229 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 ...
Joshua's user avatar
  • 101
1 vote
1 answer
38 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>...
IronMan's user avatar
  • 41
1 vote
1 answer
112 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("...
user3384741's user avatar
2 votes
3 answers
144 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?
user2395's user avatar
3 votes
1 answer
147 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 ...
Bruno's user avatar
  • 8,140
1 vote
2 answers
141 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?
Bruno's user avatar
  • 8,140
5 votes
1 answer
162 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?
Bernardo Rodrigues's user avatar
3 votes
1 answer
89 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 ...
IronMan's user avatar
  • 41
5 votes
1 answer
100 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.
ExplodingJay's user avatar
4 votes
1 answer
68 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 ...
forgetso's user avatar
  • 1,462
3 votes
1 answer
97 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 ...
Jimmy Chu's user avatar
  • 185
11 votes
3 answers
560 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, ...
edmassarani's user avatar
11 votes
2 answers
183 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 ...
Torsten Stüber's user avatar
3 votes
2 answers
143 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 ...
Kanishka's user avatar
  • 465
9 votes
1 answer
73 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 ...
Andreea Eftene's user avatar
8 votes
1 answer
92 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 ...
nazar-pc's user avatar
  • 539
6 votes
2 answers
192 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 ...
ExplodingJay's user avatar
8 votes
4 answers
1k 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`). ...
Kar Keung Christopher Fok's user avatar
10 votes
3 answers
368 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 ...
user16756428's user avatar