Questions tagged [smart-contract]
Everything smart contract related, either WASM or EVM based.
271
questions
2
votes
1
answer
146
views
how to add contract pallet into polkadot-v0.9.31
I want to add contract pallet into polkadot-v0.9.31, but there is no tutorial in [official documentation][1], and it seems that pallet-contracts-rpc-runtime-api not exists.
How can I add contract ...
2
votes
4
answers
99
views
ink-e2e: Metadata artifacts not generated when importing crate
Context:
I am trying to detach end-to-end tests from my main contract lib.rs. I created a new module in tests_e2e.rs.
I import the module in main contract like so:
lib.rs...vvv
#[cfg(all(test, feature ...
1
vote
1
answer
53
views
Accessing values in cross-crontact calling
I have followed this tutorial to create a cross-contract calling in ink. There are two contracts in the example accumulator and delegator. The accumulator contract has two functions and the delegator ...
2
votes
1
answer
94
views
Create multiple contracts in one ink
I want to create two contracts in one ink file. The second contract use functions and mapping of the first contract. Here is an example
#[ink::contract]
mod contract_1 {
pub struct Struct1 {}
#...
2
votes
1
answer
58
views
"Contracts on Rococo" down?
gm, tried setting up my boilerplate https://inkathon.xyz with contracts on rococo as suggested in the docs: https://use.ink/testnet.
unfortunately, neither i'm able to receive funds from the faucet (...
0
votes
1
answer
58
views
how to iterate a mapping with values as a struct
I have a mapping that has values and I would like to iterate the map and display the results that satisfy the condition and return the results as the array. The function looks like this
fn iterate_map(...
3
votes
1
answer
90
views
Mapping throws error when trying to use custom struct INK 4.0 beta
I'm trying to use a custom struct inside a Mapping, but I get many errors when trying to compile my code.
Here is the custom struct I want to use inside a Mapping:
#[ink::storage_item]
pub struct ...
8
votes
1
answer
310
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. ...
0
votes
2
answers
2k
views
How to convert usize to u32 in ink!
How can I convert a usize to u32?
For example I want to store the length of a Vector (usize) to a variable u32
I tried
i32::from(v) // or v.into(). where v is the length of the vector but errored
I ...
0
votes
1
answer
52
views
Difference between {Contract}Ref and Hash?
while contract instantiation inside constructor new function parameter, we can find {Contract}Ref and Hash. If new function accepts {Contract}Ref
as parameter, then type is AccountId
and if new ...
3
votes
1
answer
32
views
Supported interfaces for ink! contracts (like EIP-165)
Is there a way in ink! to check supported contract interfaces?
EVM has EIP-165. I know we have very few PSPs but already the interface information could be useful for PSP34/37 or say RMRK.
What would ...
0
votes
2
answers
101
views
Balance got Reserved while deploying wasm contracts?
i am using pallet-contracts in my substrate based chain when i am deploying the wasm smart-contract some balance is getting reserved.How can i stop this i don't want to reserve the balance,Or is there ...
1
vote
1
answer
51
views
Ink Contract's nonce doesn't increase on internal transaction
I have two contracts; adder and accumulator.An inc method on the adder contract internally calls a method on the accumulator contract to increase the accumulator's value by 1.
Using my wallet on ...
3
votes
1
answer
103
views
How to build multiple ink contracts from a root folder?
I have a simple parent folder and multiple contracts inside it in a simple structure as follows:
contracts
|__contract1
|__contract2
I add a root Cargo.toml file under contracts and ...
0
votes
1
answer
88
views
Cross-Contract execution in Ink contracts
#[ink(message)]
pub fn test_cross_contract_call(
&mut self,
calls_count: u64,
) {
let selector: Selector = Selector::new([0x6b, 0x25, 0xcb, 0x19]);
let ...
1
vote
1
answer
109
views
Out of gas Error for Contract execution
#[ink(message)]
pub fn dummy_function(
&mut self,
value: u64,
) -> u64 {
debug_println!("inside user contract dummy_function");
return 45 * ...
0
votes
1
answer
52
views
How can we generate the go wrappers for the ink smart contracts?
I built one smart contract using ink!. I can make the contract's wasm and metadata files. Now, I need to create go bindings of my smart contract to find contract types and functions info in golang ...
1
vote
1
answer
42
views
How to verify `pallet-identity` identities via signature
I'm considering using an identity service such as pallet-identity in my smart contract and would like to know if it's possible to verify an attestation that has been judged on pallet-identity such as: ...
0
votes
1
answer
32
views
"Contract Too Large", not able to deploy contract on rococo
I am deploying my contract on the rococo network and my contract wasm build size is 137K
Original wasm size: 188.1K, Optimized: 137.0K
Can you help on how to reduce the code size or any other ...
0
votes
1
answer
57
views
How to set caller and pass fee value in ink test-cases?
In my contract function, I am checking who is the transaction caller. Since I am not setting the caller in the test-cases, It might be the issue.
I would to know how to set caller_id and how to pass ...
1
vote
2
answers
157
views
How to decode error that occurred while calling a write method on ink contract, on the client side?
While calling a read only method on my ink contract, I get an error that looks like following
On my contract, I have a check to throw an error like:
if paid <= MIN_VESTING_AMOUNT{
return Err(...
1
vote
1
answer
87
views
What is new way to implement custom data structs (in ink! 4)?
I am trying to upgrade then compile a token contract (employing openbrush) from ink!3 to ink!4.
My understanding is that SpreadAllocate, StorageLayout, etc. have been removed from the ink!4 release.
...
1
vote
1
answer
258
views
Cross contract testing by ink! e2e
Hi guys I'm new to Rust and new to ink!, so please bear with me if I asked some silly questions.
My code is here. It comprises of an ERC20 contract and a main contract which contains some function ...
0
votes
1
answer
172
views
ERROR: Error invoking `cargo metadata` when trying to compile INK! 4.0 smart contract
When I compile a specific INK! 4.0 smart contract i get the following error:
ERROR: Error invoking `cargo metadata
I have multiple INK! 4.0 smart contracts that are compiling successfully without the ...
0
votes
1
answer
57
views
Is it possible to integrate a third-party library into a smart contract using ink!
I want to integrate a third party library into my ink! smart contract and I am not sure if this is possible. I did notice that ink! has something called Chain Extensions which can allow a smart ...
2
votes
2
answers
118
views
Unable to deploy INK 4.0 beta smart contract
I'm trying to deploy INK 4.0 smart contract with cargo-contract 2.0 beta to a network but I'm getting the following error contracts.CodeRejected.
Whenever i try to upload the contract to my local ...
5
votes
2
answers
723
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 ...
1
vote
1
answer
46
views
Ink Contracts: What Data Structures/Situations Are Best Suited To Contract Storage vs Events?
Using events to write data to the chain is great for registering information to the chain, especially information that you want a permanent record of. So my question is: under what circumstances ...
2
votes
1
answer
153
views
Need Help Understanding ink! Contract Storage And Data Access
There are some aspects of ink! contract storage and data access that I cannot find the answers to in the documentation or by experimentation. Here are my questions...
Is it true that there can be ...
0
votes
1
answer
68
views
Contract not compiling. "Failed to resolve: use of undeclared type `SecretKey`
Here are the steps i have done:
cargo contract new flipper
in contract code i added these lines of code:
use blst::min_pk::SecretKey; after #![cfg_attr(not(feature = "std"), no_std)]
&...
1
vote
1
answer
59
views
Transaction fees withdraw/deposit in
I made transactions on a simple EVM DEX contract.
I initially called the approve method which only triggered balances.withdraw event. I understand that this event is triggered as calling this write-...
0
votes
2
answers
47
views
Ink Message must not be generic Warning
on writing to: &mut AccountId, it throws warning to use explicit lifetime name needed here.
#[ink(message)]
pub fn delegate(&mut self, to: &mut AccountId) {
let caller = ...
1
vote
1
answer
189
views
How to achieve native token transfers between accounts in ink?
I would like to know how to achieve native token transfers between different accounts in ink? For example, I would like to initiate transfer from Alice(which will be the caller) to Bob within a method,...
3
votes
2
answers
96
views
Is there any way to verify ink smart contract
I need to verify the ink smart contract code with deployed contract. Just like solidity verification.
Anyone can give me a clue how to do so and any existing tool?
1
vote
1
answer
138
views
What is Contract Terminate?
Is contract terminate means stop the currently executed smart contract or delete it from Blockchain?. If terminate means stop, then will it be resume later and If terminate means delete from ...
1
vote
1
answer
52
views
polkadot.js | SignAndSend SuccessResponse does NOT contain all events emitted in tx
SignAndSend SuccessResponse that is a result of a contract call does NOT contain all events that are emitted during tx execution. The Object contains only events emitted from the contract that is ...
0
votes
1
answer
138
views
"CodeRejected" when trying to deploy INK smart contract using M1 pro
Im trying to deploy INK! 3.3.0 smart contract to my local substrate node and Im getting
CodeRejected; Can't decode wasm code.
When I compile my code i get no errors and using the following command to ...
1
vote
1
answer
106
views
Cannot deploy on Contracts-UI using local node
I'm following this tutorial. My local node seems to run fine but I can't deploy. The "Next" button is greyed out and there is no message that says what's wrong. What am I missing?
Contracts-...
1
vote
1
answer
79
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 ...
2
votes
1
answer
68
views
How can we omit approve function?
Now I'm building ink! smartcontract based AMM, as you know there are needed to approve before adding liquidity in general. but it's bad UX for users cuz we need to approve several times before adding ...
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 ...
2
votes
3
answers
226
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 ...
0
votes
1
answer
51
views
How to use Mapping with Sha2x256 in ink smart contracts
I want to try and use Mapping with Sha2x256 or any other value that is large enough so that each of these will be unique.
I want mapping to be like this:
unique_ids: Mapping <Sha2x256 ,u128>
...
2
votes
1
answer
48
views
The crate "pallet-contracts-rpc" does not exists for the branch "polkadot-v0.9.31". Is there any replacement?
Branch(polkadot-v0.9.31)
https://github.com/paritytech/substrate/tree/polkadot-v0.9.31/frame/contracts
Branch(polkadot-v0.9.30)
https://github.com/paritytech/substrate/tree/polkadot-v0.9.30/frame/...
1
vote
1
answer
47
views
Using conditional compilation in ink!
My question is quite simple - can I use conditional compilation via cfg attribute macros in ink! contracts?
Example:
Cargo.toml
cross_contract_emit = []
lib.rs
#[cfg(not(feature = "...
0
votes
1
answer
77
views
PSP34Mintable::mint() as payable function
I'm using PSP34 from openbrush in ink! contract and want to override mint() function that comes with PSP34Mintable trait.
Since this contract should accept payments for the mint() call, a payable is ...
2
votes
1
answer
63
views
is there any method in polakdot.js api to multi-call smart-contract's function?
Is there any method in polakdot-js api to multi-call smart-contract's function similar to https://github.com/makerdao/multicall ?
I want to fetch balances of multiples psp22 token's balance.
For ...
1
vote
1
answer
119
views
swanky deploy throws error " ENOENT: no such file or directory"
I am using Swanky Suite, contract compile successfully but while deploy using swanky deploy --account alice --contract flipper --gas 100000000 --args true throws ENOENT: no such file or directory, ...
1
vote
1
answer
86
views
Migration from ink! 3.3.1 to upcoming 4.0
Will it be possible to upgrade from ink! 3.3.1 to ink 4.0 on-chain via set_code_hash while keeping the contract storage?
A lot of questions are rising from ink! 4.0 so any other clarification is ...
0
votes
2
answers
55
views
Do we have CLI support for ink! smart contract deployment on configured test-net?
I want to deploy my contract on Rococo contract test net. Apart from polkadot.js/apps, do we have any other way to upload and then instantiate the contract?
My goal is to create a script for the ...