Questions tagged [smart-contract]
Everything smart contract related, either WASM or EVM based.
270
questions
3
votes
1
answer
64
views
How to "graceful terminate" a smart contract from the "rococo-contracts-rpc.polkadot.io" chain?
In theory we could use this command:
cargo contract remove --execute --code-hash '******' --url 'wss://rococo-contracts-rpc.polkadot.io' --suri 'seeds'
But in order to do that we have first to ...
0
votes
1
answer
27
views
"TooManyTopics" Dispatch Error and Contract Revert when Minting in OpenBrush PSP37 Smart Contract
I am facing an issue with the OpenBrush PSP37 smart contract while calling the mint function. I receive a Contract Reverted! error with a TooManyTopics dispatch error. However, upon inspecting the ...
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 ...
5
votes
1
answer
64
views
How do I upgrade an ink contract with storage changes?
Let's say I have a simple/contrived ink contract:
#[ink(storage)
pub struct MyContract {
a: u8,
b: u8,
}
Now let's say it's in production and a == 1 and b == 2.
I've done some work and ...
3
votes
0
answers
57
views
Can we define ink_e2e tests outside of contracts module?
devs. I am writing the e2e tests for my smart contracts using ink_e2e
In contracts, I define the e2e-tests like this.
#[openbrush::contract]
pub mod controller {
...
#[cfg(all(test, ...
3
votes
1
answer
188
views
Getting OutOfGas Error when trying to call smart contract
I am running tests of my !ink smart contracts using @727-ventures/typechain-polkadot module.
But when I am running tests, sometimes getting OutOfGas Error.
The strange thing is that not all cases are ...
2
votes
1
answer
103
views
Error while trying to run e2e rust ink! tests
Im getting the following error while trying to run e2e rust ink! smart contracts tests:
#![feature(min_specialization)] using the following command: cargo test --features e2e-tests
Im using the ...
3
votes
1
answer
57
views
Build the data bytes to query a contract with the api state_call
I would like to use the rpc call to query a contract.
I try to use the method "call" from the endpoint "state" with the first parameter "ContractsApi_call" but I am not ...
5
votes
2
answers
151
views
"ERROR: Loading of original wasm failed" after upgrading rustup
I'm getting the following error when compiling a rust ink! 4.0;
ERROR: Loading of original wasm failed
It's started happening to me after I rustup update and now my rustc versions are:
stable-...
3
votes
1
answer
70
views
Problem deploying smart contract on rococo
I have been following the public documentation of polkadot API to deploy contract: https://polkadot.js.org/docs/api-contract/start/code
but I'm getting error Uncaught (in promise) TypeError: code.tx....
5
votes
0
answers
74
views
I want to use Parity SCALE codec in Solidity? Is there any implementation of scale codec to decode bytes?
I want to decode bytes on the Solidity side that was decoded with scale codec.
Is the any implementation of scale codec (decode) on the Solidity side?
4
votes
1
answer
49
views
How to compile to wasm and deploy a custom pallet instead of an ink! smart contract to the Contracts module/pallet?
I enjoy writing custom pallets so I would like to know if instead of writing an ink! smart contract and then compiling it to .wasm and deploying it to the Contracts module/pallet of a Substrate-based ...
3
votes
0
answers
29
views
How can I use complex structure in ink! version3
how can i use the complex structure(like Mapping<String, Vec<Map<String, String>>>) in ink!
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
#[ink::...
2
votes
1
answer
52
views
I Can't Generate The right AccountId from Ethereum(H160) Address
I am writing a test to test evm contract instantiation using polkadot api.
I get to derive the evm account like this:
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
const ...
1
vote
1
answer
25
views
Calculation gives the wrong result
After doing a simple calculation in rust ink! 4.0 smart contract, the result is incorrect and doesnt match the expected result.
Here is the simple formula:
let a0_balance_mul:U256 = U256::from(...
3
votes
1
answer
61
views
Error while dividing two u128/Balance types
#[ink(storage)]
pub struct Variables {
a: u128,
b: u128,
multiplier: u128
}
impl Variables {
#[ink(constructor)]
pub fn new(a: u128, b: u128) ->...
2
votes
0
answers
37
views
How to upload the same ink! smart contract to a different code hash?
I've written this ink! quickstart script that I can repeatedly call to run these steps to flood my local testnet with instances of Flipper contracts:
Kills an existing substrate-contracts-node ...
1
vote
1
answer
67
views
Explain components of Mapping used by Openbrush. Mainly placeholders for the actual type used in the code. Like ApprovalsKey used in bellow example
I am trying to understand the working of upgradeble storage used by openbrush libraries.
I am unable to understand Mapping used in impls of psp34 trait eg
pub operator_approvals: Mapping<(Owner,...
5
votes
2
answers
79
views
Trying to implement U256 in rust ink! 4.0
I've implemented use primitive_types::U256 and now I'm trying to return a U256 int as a result from one of my functions, but I'm getting the following error: the trait TypeInfo is not implemented for ...
3
votes
0
answers
29
views
How to migrate / backup & restore ink smart contract storage?
Is there a way to backup ink smart contract storage and later restore on another chain? Lets say we have chain with 3 validators and deployed smart contract containing certain information in its ...
1
vote
2
answers
63
views
"the wasm*-unknown-unknown targets are not supported by default" -error while compiling ink smart contract
I am attempting to build a smart contract for an imaginary burger shop. But I keep getting this error when I run the build command.
The test compiles, and cargo check compiles successfully too.
Here ...
2
votes
0
answers
29
views
Error Type { registry: TypeRegistry {}, initialU8aLength: 6 } when try to query ink! smart contract by @polkadotjs/api-contract
My code:
const main = async() => {
//Get wasm
// This file wasm I already build through "cargo contract build"
let wasm = fs.readFileSync("../../res/incrementer.wasm&...
2
votes
2
answers
76
views
How to get the ContractRef from AccountId or codehash with Ink!
From the ink! cross-contract docs, contract references give developers a type-safe way of interacting with a contract. However, this is not only available when the contract is already instantiated.
My ...
4
votes
1
answer
34
views
How can i query pallet contract to give the Scale codec value of a Contract Root Storage Key
According to ink!:
"Storage data is always encoded with the SCALE codec. The storage API operates by storing and loading entries into and from a single storage cells, where each storage cell is ...
2
votes
1
answer
53
views
Error when implementing contract-pallet into substrate-node-template
I was looking to implement smart-contract into substrate-node-template as I do not want to use substrate-contracts-node.
I was trying to follow this guide - https://substrate-developer-hub.github.io/...
2
votes
1
answer
53
views
Polkadot-JS not calling my contract properly
I used PolkadotJS to call a contract, when i did, it logged the status "in block", Turns out it never makes any state change. I used contracts-ui it worked, but with JS? Never. What can be ...
4
votes
2
answers
552
views
Factors affecting storage field key generation in ink!
I've got a couple of questions regarding the storage fields' key generation using AutoKey in the context of upgradable contracts and partial ManualKey usage.
Does the use of ManualKey in some storage ...
2
votes
2
answers
237
views
Do ink compiler automatically generate getter function for state variable ( if declared as public ) like solidity language?
In the case of solidity language -
In smart contracts, state variables can be made public to allow for easy access and visibility of the data stored in the contract. When a state variable is declared ...
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 ...
2
votes
1
answer
63
views
How to run ink! e2e tests in GitHub CI
The directory structure for my project is something like this
ink
- contract
runtime
node
and so on
I want to run the contract ink/contract e2e tests in GitHub CI using my own node instead of the ...
2
votes
1
answer
71
views
PSP34 Get Attribute Null Value
I Already write code with openbrush.io and set Attribute on constructor here my code :
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#[openbrush::...
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 ...
1
vote
1
answer
18
views
change_forward_address method Disappeared
I follow this instruction link to deploy an upgradable contract link. When I have to deploy the contract only gives me 2 methods flip and get. When I want to change the forward contract to invoke the ...
4
votes
1
answer
101
views
Encode strings to SCALE encoded smart contract calls
I'm looking for a way to encode smart contract calls in javascript code with polkadot-js, the same way I can do it from the web UI, but I cannot find a description of the available API in the ...
1
vote
3
answers
113
views
Unable to deploy the open-brush contracts build using toolchain nightly-2023-02-07 on substrate node
As you can see in following link . I was not able to build contract using latest rust nighly ( rustc 1.70.0-nightly (17c116721 2023-03-29)) toolchain.
ERROR: Loading of original wasm failed
I got the ...
9
votes
1
answer
117
views
Smart Contract blockspace allocation in Hybrid Chains
In Rob Habermeier's blogpost about Hybrid Chains, he mentions allocating contract execution to a limited fraction of the chain's blockspace.
Is that some functionality that pallet-contracts provides?
...
2
votes
1
answer
73
views
How to decrease wasm smart contract deployment fee without decreasing Transaction fee?
i am using substrate pallet_contracts for wasm contract deployment how can i set the fees for contract deployment?
8
votes
4
answers
143
views
Managing deployment of complex set of wasm contracts
We need to deploy a set of several smart contracts, x-compiled from Solidity to wasm, and maintain that deployment (deploy new contract instances and migrate to them once in a while).
So what we ...
3
votes
1
answer
85
views
Call a smart contract ink! as a argument of another smart contract
I have a question about ink!. Is it possible from a smart contract A to manage the transfer of tokens of contract B IF contract B will be deployed later ?
I want a user to call a function of smart ...
5
votes
2
answers
103
views
Problem with Vec using ink
I'm trying to make some changes to the Flipper contract, trying to use a vector like the documentation say's it should be imported:
#[ink::contract]
pub mod flipper_plus {
use ink::storage::...
4
votes
1
answer
197
views
Caching of smart contract storage reads
Wanted to get some clarity on repeated reads.
Assuming this is the contract storage, two values both under the default 0x00000000 key in the storage.
#[ink(storage)]
pub struct MyContract {
pub ...
3
votes
3
answers
92
views
How to sign an extrinsic as a smart contract in the browser?
When working with smart contracts in Contracts UI you sometimes need to call a message as the contract itself.
For example the addOwner message of the Multisig ink! example.
How can I add the contract ...
1
vote
1
answer
74
views
Implementing a DEX with Substrate on the Polkadot Network, Allowing Custom Token Creation and Addition
I am in the process of developing a decentralized exchange (DEX) using Substrate on the Polkadot network and could use some assistance with the implementation. The key features I want to incorporate ...
0
votes
1
answer
35
views
Can I make a cross-contract call with constructor (function with "#[ink(constuctor)]" attribute) in ink! contract?
I've been trying to implement cross contract calls in constrcutor but somehow I can't seem to make it right. Is the following code executable?
#[openbrush::contract]
pub mod contract {
#[ink(storage)...
1
vote
2
answers
155
views
StorageDepositLimitExhausted error when trying to deploy contract on Rococo
I got this error when I was trying to deploy my ink! smart contract on Rococo:
**StorageDepositLimitExhausted
More storage was created than allowed by the storage deposit limit.**
What might be the ...
0
votes
1
answer
55
views
Unable to upload Phat Contract build using cargo-contract-2.1.0
I was unable to add contract into https://phat.phala.network/contracts/add.
At the
The contract was built using:
cargo-contract version : cargo-contract-contract 2.1.0-unknown-aarch64-apple-darwin
the ...
2
votes
1
answer
50
views
What should the end-user expect after a cross contract call failure
I was attempting to comprehend the workings of cross-contract calling in substrate ink contracts using this particular sample code.
If I provide u64::MAX as the calls_count value, it will result in a ...
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 ...
4
votes
2
answers
87
views
How do i pass a `Vec<u8>` as argument to a contracts function, using the command line(cargo contract)
When using cargo contract to call contracts, in all the examples i've seen, its either been AccountId or boolean or integers(u & i). I need to pass a Vec<u8> to my contract function. I've ...
2
votes
1
answer
144
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 ...