Questions tagged [smart-contract]

Everything smart contract related, either WASM or EVM based.

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

Could not decode `ContractInfo::storage_item_deposit

When I am doing runtime-upgrade from polkadot-v0.9.38 to polkadot-v0.9.39 .I am getting one issue of smart contract in my terminal 2023-09-18 11:36:25 Corrupted state at `[67, 66, 25, 62, 73, 111, ...
Arunjot Singh's user avatar
1 vote
1 answer
37 views

Contract Trapped on Single Message

I am getting a Contract Trapped error on one specific message in my ink contract. I tried putting overflow-checks = false into the Cargo.toml. That made no difference. This is the first time I have ...
KathrynColleen's user avatar
3 votes
0 answers
26 views

Is there a way to instantiate a contract from code_hash without ContractRef

From the documentation, we have 2 ways of instantiating a contract from a code_hash, but both require a ContractRef. In order to obtain ContractRef we have to import the contract crate as a dependency ...
Thang X. Vu's user avatar
0 votes
0 answers
38 views

Unable to verify WASM contract in Substrate Astar

I'm encountering difficulties while attempting to verify my WASM smart contract through Astar's Subscan tool. Despite multiple attempts using various options, the verification process remains ...
Tom Rowbotham's user avatar
1 vote
1 answer
92 views

how to call smart contract function in custom pallet?

Is there any way to call ink! smart contract function in substrate custom pallet? We've found this answer where bare_call function is based on older version of contract_pallet. // This ends up calling ...
Ganesh11's user avatar
  • 1,148
1 vote
1 answer
25 views

Call ink! smart contracts from hardware devices that use embedded rust

What would be the best rust crate or c++ libraries to call ink! smart contracts from hardware devices that use embedded rust?
Evil Kyle's user avatar
  • 149
1 vote
1 answer
39 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, } ...
Evil Kyle's user avatar
  • 149
3 votes
1 answer
38 views

What is a Storage Deposit?

When developing ink smart contracts, I've often seen a Storage Deposit charge. What is this, and how does it relate to contract storage? My guess is it's a charge related to the size of the contract's ...
goastler's user avatar
  • 519
1 vote
0 answers
19 views

How to resolve "mismatched types" error while ink_e2e test : expected String, found Vec<u8>

I am working with ink_e2e testing framework in ink smart contract, and I have encountered an error message that's a bit confusing. The error says: mismatched types - expected String, found Vec<u8&...
UPENDRA SINGH's user avatar
0 votes
0 answers
22 views

Selling token to any third party tools

When user stake his NFT, then he earns certain amount of $EGGS token which is in-game currency. He can to sell those token to third party tools. How to implement selling token to any third party tools ...
Ganesh11's user avatar
  • 1,148
0 votes
1 answer
20 views

Error in deploying call_runtime contract from ink!

I am running call_runtime from ink. It builds successfully, but when trying to upload contract, It gives system.ExtrinsicFailed contracts.CodeRejected error. Someone please advice what I am doing ...
Ganesh11's user avatar
  • 1,148
1 vote
1 answer
27 views

How to write integration test cases for ink?

I am new to substrate and ink, while following ink documentation I got to the testing part and want to write integration tests. Can someone help me with it or point to the documentation or resources ...
Shivam Varshney's user avatar
1 vote
0 answers
24 views

What happens to legacy contracts given breaking changes to cargo-contract v3?

In the cargo contract v3 release, breaking changes were made for how contracts are built (cdylib -> bin) and specifying no_main. I've found that cargo contract v2 produces contracts compatible with ...
goastler's user avatar
  • 519
4 votes
1 answer
58 views

rococo-contracts-rpc.polkadot.io, upgrade their nodes to the latest avaliable version

Does anyone know when the rococo-contracts-rpc.polkadot.io is going to upgrade their nodes to the latest available version ? Error: Ink version:
Evil Kyle's user avatar
  • 149
0 votes
1 answer
109 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-...
Evil Kyle's user avatar
  • 149
0 votes
0 answers
28 views

Event on factory can't be emitted

I'm working on an an ink! contract and trying to establish a factory contract to enable indexing for each deployment using a subquery subgraph. For this purpose, we emit an event whenever a successful ...
Gabriel Gonzalez's user avatar
2 votes
1 answer
193 views

Writing Unit Tests

I have two ink! contracts, one being a simple staking contract, and the other being an ERC20. Now, I can write unit tests for ERC20 simply in the contract file itself but to write unit tests for my ...
ProgrammerForFun's user avatar
0 votes
1 answer
51 views

Get contract address from instantiated ContractRef

Based on this example: https://docs.rs/ink/latest/ink/struct.EnvAccess.html#method.instantiate_contract Im doing something similar: #[ink(message)] pub fn new_multisig(&mut self, threshold:...
Luca Auet's user avatar
1 vote
2 answers
93 views

Not able to upload contract in substrate node template

I have added pallet-contract in our chain. Build contract works fine and run chain in dev mode also works fine. But when I try to deploy contract it doesn't work and doesn't throw any error. Can ...
Ganesh11's user avatar
  • 1,148
1 vote
1 answer
32 views

Calculate how many days

I wan't to get how long user has staked nft token in days. I recorded staking time_stamp while staking and un_staking time_stamp while un_staking. Now I wan't to calculate how many days user has ...
Ganesh11's user avatar
  • 1,148
0 votes
1 answer
20 views

block time_stamp return value

When using block_timestamp to return value, why it's return 1,690,534,220,344 value? Someone please explain me what is the meaning of this value? #[ink(message)] pub fn abc(&self) -> u64 { ...
Ganesh11's user avatar
  • 1,148
0 votes
0 answers
52 views

How to wrap an ink::env::Error in a Custom Error?

In my contract, I have a requirement to call messages from external contracts without knowing their specific identities beforehand. To achieve this, I utilize the call builder, enabling the execution ...
Luca Auet's user avatar
0 votes
1 answer
15 views

Error upload smart contract

The pallet-contract version is 0.9.29 Error uploading new contract using Polkadot.JS
hgminerva's user avatar
  • 467
1 vote
2 answers
77 views

Reading contract value returns null

Facing an issue while trying to query for a value in my contract. The value keeps getting retuned as null with an error. However, it works fine on substrate Contracts UI Front end Dapp : const ...
0xD1x0n's user avatar
  • 119
2 votes
1 answer
52 views

Generate random number ink!

I am writing ink! contract to generate random number between min and max value. I found this article. Here we can generate random number between 0 to 99. Then I modified to generate random number ...
Ganesh11's user avatar
  • 1,148
0 votes
1 answer
25 views

How to implement EIP-2612 permit in rust !ink

I am trying to implement EIP-2612 permit functionality in my psp22 contract. https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md But not sure how to do it. ...
Wolf's user avatar
  • 61
2 votes
2 answers
28 views

Ink Smart Contract call Error

I am deploying an ink! smart contract to a local network, but when I tried to call any function from it i have this error: > { Err: { Module: { index: '8', error: '0x02000000' } } } Does anyone ...
Fred's user avatar
  • 21
1 vote
1 answer
56 views

How to mint multiple characters randomly?

Let me give scenario, let's say: There are 2 types of playable characters Chickens (90% chance to mint) Foxes (10% chance to mint) and total supply is 15,000 units : 13,500 chickens 1,500 foxes ...
Ganesh11's user avatar
  • 1,148
0 votes
1 answer
31 views

How to deploy a contract on your chain

Hi i have cloned the node-template and also added the pallet-contract in it, now i want to know that how can i deploy a smart contract on my chain i have also deployed it on EC2 instance but i want to ...
Abubakar Mujahid's user avatar
1 vote
2 answers
37 views

Sending native token in loop not running

Please explain why the following occurs When this method is called, the tokens are equally divided and distributed to the user. (as expected) All user balances get updated with the new amounts. #[ink(...
0xD1x0n's user avatar
  • 119
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 ...
Evil Kyle's user avatar
  • 149
0 votes
1 answer
25 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 ...
UPENDRA SINGH's user avatar
1 vote
1 answer
49 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 ...
UPENDRA SINGH's user avatar
5 votes
1 answer
49 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 ...
goastler's user avatar
  • 519
3 votes
0 answers
54 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, ...
Wolf's user avatar
  • 61
3 votes
1 answer
177 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 ...
Wolf's user avatar
  • 61
2 votes
1 answer
79 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 ...
yonatan hornstein's user avatar
3 votes
1 answer
50 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 ...
GuiGou's user avatar
  • 31
5 votes
2 answers
123 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-...
yonatan hornstein's user avatar
3 votes
1 answer
59 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....
Nikola Bozin's user avatar
5 votes
0 answers
63 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?
rust.dev's user avatar
  • 511
4 votes
1 answer
43 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 ...
Vinh Real's user avatar
3 votes
0 answers
26 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::...
user4298's user avatar
2 votes
1 answer
40 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 ...
dharjeezy's user avatar
  • 399
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(...
yonatan hornstein's user avatar
3 votes
1 answer
49 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) ->...
abhi arjun's user avatar
2 votes
0 answers
33 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 ...
Luke Schoen's user avatar
  • 2,262
1 vote
1 answer
61 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,...
UPENDRA SINGH's user avatar
5 votes
2 answers
62 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 ...
yonatan hornstein's user avatar
3 votes
0 answers
25 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 ...
Alex 's user avatar
  • 83

1
2 3 4 5