assert-balance
Assert the native balance of an account, on-chain.
Syntax
Section titled “Syntax”assert-balance <account> <operator> <expected> [message]Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
account |
address |
Account to check |
operator |
string |
Comparison operator: ==, >, <, >=, <=, ~= |
expected |
number |
Expected balance in wei |
[message] |
string |
Revert message when the assertion fails |
Options
Section titled “Options”| Name | Type | Description |
|---|---|---|
--delta |
number |
Allowed delta for the ~= (approximate) operator |
Examples
Section titled “Examples”load assertions
# Require an account to hold more than 1 ETHassertions:assert-balance @me > 1e18 "needs ETH"
# Approximate balance within a deltaassertions:assert-balance @me ~= 5e18 --delta 1e17 "balance drifted"