0

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 any way i can fix the minimum amount to be reserved?

impl of pallet_contracts in node runtime

impl pallet_contracts::Config for Runtime {
type Time = Timestamp;
type Randomness = RandomnessCollectiveFlip;
type Currency = Balances;
type Event = Event;
type Call = Call;
type CallFilter = Nothing;
type DepositPerItem = DepositPerItem;
type DepositPerByte = DepositPerByte;
type CallStack = [pallet_contracts::Frame<Self>; 31];
type WeightPrice = pallet_transaction_payment::Pallet<Self>;
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
type ChainExtension = ();
type DeletionQueueDepth = DeletionQueueDepth;
type DeletionWeightLimit = DeletionWeightLimit;
type Schedule = Schedule;
type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
type ContractAccessWeight = pallet_contracts::DefaultContractAccessWeight<RuntimeBlockWeights>;
type MaxCodeLen = ConstU32<{ 128 * 1024 }>;
type RelaxedMaxCodeLen = ConstU32<{ 256 * 1024 }>;

as we can see 195,909,000,000,000,000 is getting reserved from the Bob account and 501,000,000,000,000 is reserved in my contract how can i lower the amount or completely remove it??

2
  • 1
    can you send the config of the pallet_contract in the runtime of your node? or where are you deploying the smart contract
    – Alex Bean
    Jan 31, 2023 at 9:16
  • 1
    @AlexBean i have updated the question. Jan 31, 2023 at 9:30

2 Answers 2

1

we can make changes in impl pallet_contracts::config for Runtime

type DepositPerItem = DepositPerItem;
type DepositPerByte = DepositPerByte;

if you don't want to reserve any balance then make changes to pallets_contracts::config

    type DepositPerItem = ();
    type DepositPerByte = ();
1

To add to your answer:

pallet-contract implements automatic deposit collection:

Additionally to the weight, there is also a fee paid for on-chain storage called automatic deposit collection. This additional fee is paid by the caller and is calculated with the price set for each storage item DepositPerItem and the price charged for each byte of storage DepositPerByte.

The automatic deposit collection can be simplified as follows:

A caller of a contract pays a deposit to each contract in which new storage was created as a result of the executed call. In a similar way, a caller gets a refund from all the contracts that the call removed storage from.

This mechanism insure that there is no spam from storing on-chain storage. If you set it to 0 anyone can, for free, upload a lot of (wasm blobs) contracts or bloat contract storage without an economic way to avoid it.

1
  • Once the deployed contract is terminated, shouldn't the funds be unreserved and moved to free balance?
    – Bukks
    Feb 1, 2023 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.