2

How do i figure out that how many rents should i pay? If i use the rpc api named "getMinimumBalanceForRentExemption" , I really don`t know "account data length"

1
  • The amount of rent you will need to pay is dependent on the data you were trying to store in the account. What type of account are you trying to create? If you are trying to create and fund a simple account that only stores tokens, the data length should be zero.
    – nickfrosty
    Commented Sep 25, 2022 at 1:41

1 Answer 1

1

The https://docs.solana.com/developing/clients/jsonrpc-api#getminimumbalanceforrentexemption signature expects you to know the size of the account you are going to create.

Best practice to assume the max length of the account and create it.

Here is an example on how it all works for Solana Token Program (in this case, the account structure is known and hence the size 165 ) - https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L126

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.