testing
no_std
+ WebAssembly as targetstd
#[ink::test]
will simulate on-chain modestorage
#[ink(storage)]
struct will be pulled from storage, regardless of whether or not they are used during the message execution.#[ink(storage)]
pub struct EagerLoading {
a: i32,
b: ink_prelude::vec::Vec<i32>, // may be large
}
impl EagerLoading {
#[ink(message)]
pub fn read_a(&self) {
// b will be loaded as well
let a = self.a;
}
}
Prevent using Rust stdlib collections, since they are not optimized for smart contract usage
Vec
or a HashMap
where the smart contract might only need access to a few elements, rather than the entire data collection.ink! vs. Solidity | ink! documentation
uint256
u128
is the largest[u64; 4]
SpreadAllocate
trait on our storage structink_lang::utils::initalize_contract
initializerBTreeMap
+ PackedAllocate
AccountId
of an already deployed contract.EVM is rather limited and slow
Contract pallet integrates a Two Step Deployment to decouple contract code and contract instances
Two Step Deployment:
Deploying a contract with the Contracts module takes two steps:
This means that multiple contract instances, with different constructor arguments, can be initialized using the same Wasm code, reducing the amount of storage space needed by the Contracts module on your blockchain.
#![cfg_attr(not(feature = "std"), no_std)]
?
if feature != "std":
enable no_std -> WASM on-chain mode
else:
std is enabled -> off-chain mode