Skip to main content

All Questions

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

how to remove Mapping storage when tuple is used as input

Lets assume we have an ink! smart contract On a vanilla Mapping alpha: Mapping<[u8;32], Astruct> we can use self.alpha.remove(&somehash) My question is this: if we have the following ...
Sokrates's user avatar
  • 421
3 votes
1 answer
136 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
  • 579
1 vote
1 answer
46 views

Is there an `OrderedMapping` storage type available in ink?

I'm new to ink! smart contracts, and trying to figure out how to set up my storage. I have a basic DAO. The DAO has members, and each member has a score (a u128) associated. So far a mapping sounds ...
JoshOrndorff's user avatar
  • 1,211
5 votes
1 answer
84 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
  • 579
4 votes
1 answer
62 views

How much do data structures contribute towards ink contract storage size?

I've used Mapping, BTreeSet, BTreeMap and Vec for various purposes in our ink contract and have observed the contract size fluctuating based on usage of these four data structures. This leads me to ...
goastler's user avatar
  • 579
3 votes
0 answers
32 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
5 votes
1 answer
54 views

Fixed size array in ink smart contract storage

How can I have a fixed size array in my ink smart contract storage? E.g. // Contract storage #[ink(storage)] pub struct MyContract { myArray: [u8; 64] } I get "the trait ...
goastler's user avatar
  • 579
9 votes
0 answers
104 views

What are the size limits of contract storage in ink?

Whilst reading the docs for ink I came across this warning: CAUTION If any type exhibiting Packed layout gets large enough (an ever-growing Vec might be a prime candidate for this), it will break ...
goastler's user avatar
  • 579
2 votes
1 answer
124 views

BoundedVec on ink!

BoundedVec is a vector where the length of the queue is always bounded, which is better than Vec for storage because it has a defined a maximum length. I recommend this StackExchange questions to ...
Alex Bean's user avatar
  • 5,767
2 votes
1 answer
56 views

What is a storage cell?

Somewhat noob question: I see the term storage cell talked about a lot on here (mostly regarding Mapping and Lazy), however I cannot find any documentation about it. What exactly is a storage cell? ...
goastler's user avatar
  • 579
6 votes
1 answer
62 views

Are Vec<T> stored with unused space in ink?

I'm using a Vec<T> in ink!. When allocating elements to the vec, the underlying array may be resized to provide a constant amortised push complexity of O(1). This means that sometimes the vec ...
goastler's user avatar
  • 579
4 votes
1 answer
112 views

What is a substate contracts max storage size? using the contracts pallet

Just to clarify, I am not asking about the max upload size of a contract. I am able to upload my contract to my chain no problem. I have two smart contracts (A,B) A calls a transaction on smart ...
BRNHINLT's user avatar
  • 132
1 vote
1 answer
48 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 ...
KathrynColleen's user avatar
4 votes
1 answer
103 views

What are the fees associated with ink! contract deployment?

I see that there are many events emitted during the process of deploying my contract on Substrate local chain (SNOW Network to be specific). 4 ICZ was reserved from deployer account 1 ICZ & 2 ICZ ...
Non-named's user avatar
  • 304
1 vote
2 answers
121 views

ink!: Initializing custom structure

I have an auxiliary struct: #[derive(SpreadAllocate, SpreadLayout)] #[cfg_attr(feature = "std", derive(TypeInfo, ink_storage::traits::StorageLayout))] pub struct MerkleTree<const LEAVES: ...
pmikolajczyk41's user avatar
1 vote
1 answer
211 views

How to use keccak256 sha256 in ink smart contracts?

I want to hash string using sha256 and then store it inside of my ink smart contract. I tested this code in Rust and it works out for me: use crypto::sha2::Sha256; use crypto::digest::Digest; let ...
nanoman's user avatar
  • 11
0 votes
1 answer
56 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> ...
nanoman's user avatar
  • 11
0 votes
1 answer
79 views

Query returning all instances of a contract based on it's code hash?

Looking to write a call that could return all the contract addresses of ink contracts matching a code hash of the contract via RPC. What would be the best way to go about getting the list of contract ...
Metallurgical's user avatar
0 votes
2 answers
119 views

How to store a enumerations in smart contracts with ink?

How to store enumeration in smart contract with ink! I have a field in smart contract with type Mapping<AccountId, Enum>, I tried to use guide https://ink.substrate.io/datastructures/custom-...
Ruslan's user avatar
  • 13
3 votes
1 answer
144 views

ink! `Mapping` default initialization

The official documentation shows this about the Mapping's initialization: Is it fine if I initialize a Mapping using default? e.g. initialize_contract(|contract: &mut Self| { contract....
Pablo Corrado's user avatar
1 vote
1 answer
185 views

Does it make sense to use HashMap instead of Mapping in ink?

I'm developing a contract that should have some type of a map from AccountId to Balance and I should be able to iterate over it. Using ink_storage::Mapping I can't iterate over the collection. But ...
CREESTL's user avatar
  • 484