I'm working on a smart contract where I need to send a balance from a user account to the contract address. The amount to be sent is fixed and hardcoded in the contract. I have tried to figure out some ways, but the only thing I have found is self.env().transferred_value(). But I don't see any option to fix the amount with this method.

1 Answer 1


I believe what you are trying to achieve has to be done in the application layer. self.env().transferred_value() only returns the transferred value the user has set.

In the Smart Contract what you can do is check that the amount the user is transferring is equal to the hardcoded value you have and throw an error if is less:

let transfered_value = Self::env().transferred_value();
assert!(transfered_value < your_hardcoded_value, "insufficient amount!");

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.