Questions tagged [smart-contract]
Everything smart contract related, either WASM or EVM based.
38
questions
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`). ...
5
votes
2
answers
712
views
smart contract function call error
I am deploying flipper ink! smart contract to shibuya, but when I tried to read the value using get() I am getting this error:
{ Err: { Module: { index: 70 error: 0x02000000 } } }
I also tried ...
11
votes
3
answers
557
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, ...
4
votes
1
answer
262
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 ...
4
votes
1
answer
253
views
How does cross contract calling with openbrush work exactly?
The title of the question is a bit open ended, but I am trying to make cross contract calling work right now and realised, that there is a lot of open question on how it exactly works and how the ...
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?
3
votes
1
answer
299
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 ...
22
votes
3
answers
695
views
When should I build a Substrate FRAME Pallet versus a Smart Contract?
What are the differences between developing a Substrate FRAME Pallet and a Substrate Smart Contract (for example with the ink! language)?
What are some examples of applications which are best written ...
5
votes
1
answer
117
views
How to identify received contract event?
My contract emits several [ink(event)] events. My application subscribes to the events and receives Contracts_ContractEmitted data (from centrifuge go-substrate-rpc-client). How may I understand which ...
5
votes
1
answer
431
views
How can I call my contract methods inside a pallet?
Can someone tell me how can you execute a smart contract method inside your custom pallet?
You can call your smart contract tx/query through the RPC API but how can you call it inside a custom pallet?
...
2
votes
1
answer
70
views
Substrate tutorial: Blank page when deploying smart contract
I am following the Substrate tutorial at https://docs.substrate.io/tutorials/smart-contracts/prepare-your-first-contract/
I was able to build/compile the Flipper smart contract but when I'm trying to ...
0
votes
3
answers
228
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 ...
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 ...
10
votes
2
answers
236
views
Calling the function of an other contract in Solidity
Do you know if is it possible to call the function of an other contract in Solidity used in Substrate based chain and compiled with solang ? At first glance it seems impossible but I doubt it.
As a ...
10
votes
3
answers
365
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 ...
8
votes
1
answer
295
views
How to estimate gas for ink contracts transactions for Weights V2?
For ink contracts with weight v2 it requires refTime and proofSize. For this we are first querying(dry run) the transaction method, getting gasRequired from query result and sending it to transaction. ...
7
votes
1
answer
125
views
How to properly handle cross contract call errors
In the scenario where a cross-contract call from contract A to contract B fails, how can we manage the resulting errors? Specifically, if the call from A to B is unsuccessful, what are the options for ...
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 ...
7
votes
2
answers
340
views
How to decode ink 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?
6
votes
2
answers
204
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?
5
votes
2
answers
146
views
Is circular call between multi contracts possible?
Background
I have two contracts A and B, I can do cross-contract call from A to B, or from B to A. But it failed when I try to do cross-contract call like this: A -> B -> A.
Test code
I ...
4
votes
1
answer
82
views
Why are all the ink! Playground links broken in the official Substrate docs at substrate.dev?
If I go to https://substrate.io/developers/smart-contracts/ and click on any of the 6x hyperlinks called Open ink! Playground it takes me to https://ink-playground.substrate.io/ and returns 404 page ...
4
votes
1
answer
67
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 ...
3
votes
1
answer
82
views
What are the costs of multiple cross-contract calls in one contract call stack to callees with the same code?
As far as I know, contract calls are expensive because the called contract code must be loaded.
What if I make 2 cross-contract calls in one function to the same smart contract? Is the contract code ...
3
votes
1
answer
198
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,...
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 ...
3
votes
1
answer
146
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 ...
2
votes
3
answers
224
views
Ink! smart contract struct field issues
I am a Rust and Ink! novice so please bear with me but, I have a struct that looks like the following:
#[ink(storage)]
pub struct Contract {
test: sp_arithmetic::FixedU128,
}
Unfortunately, I ...
2
votes
1
answer
355
views
How to implement cross contract calls correctly?
I've been trying for a few days now to implement cross contract calls but somehow I can't seem to make it right. So here is my code and I hope one of you can point out my mistake to me.
I want to call ...
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?
1
vote
1
answer
62
views
Getting "Contract Reverted!" error with "TooManyTopics" dispatch error when calling mint function in OpenBrush PSP37 smart contract
I'm working on adding events to an OpenBrush PSP37 smart contract and deploying it using Substrate Contract UI. However, when I try to call the mint function, I encounter the following error:
Contract ...
1
vote
1
answer
63
views
Cross-Contract Calls and Events don't work (ink 4.2.1)
I have replicate this error using the MultiContractCaller from the ink-examples
In the multi_contract_caller we have a FakeEvent.
#[ink(event)]
pub struct FakeEvent {
account_id: AccountId,
}
...
1
vote
1
answer
78
views
How can I call my pallets and it functions in a smart contract?
How can I call my pallet functions from a smart contract?
For example I have a pallet with name dex, this pallet has some function with name A , B , C. Now I want to call and use this functions in my ...
1
vote
1
answer
70
views
Use SpreadAllocate in cross-contract calling
I'm trying to call an erc20 contract from another custom erc20 contract.
Both, the original contract and calling contract have the following macros:
#[ink(storage)]
#[derive(SpreadAllocate)]
In the ...
0
votes
1
answer
123
views
e2e-tests "We should find a port before the reader ends"
I am doing a basic E2E test using the flipper example.
This is my contract version
I have install the substrate-contracts-node
I am running with the "nightly-2023-02-09" (cargo +nightly-...
0
votes
1
answer
96
views
#[ink(constructor)] cause a error, What is wrong with it?
error: encountered unexpected ink! attribute
--> lib.rs:80:15
|
80 | #[ink(constructor)]
| ^^^^^^^^^^^
when I execute $cargo +nightly contract test , the above error ...
0
votes
1
answer
146
views
Best way to provide mock data for cross-contract calls
This question is more about best practices, and if there is a better method for providing mock data for off-chain ink! tests.
The goal is to use mock data for off-chain unit testing for ink! contracts....
0
votes
1
answer
71
views
ChainBridge: how to use their CLI tool to deploy smart contracts on Ethereum networks?
How to Ropsten, Rinkeby, Kovan, Goerli, and Kiln
From cb-sol-cli doc page https://github.com/ChainSafe/chainbridge-deploy/blob/master/cb-sol-cli/docs/deploy.md
It is not very clear or easy to use this ...