@token:allowance
Fetch the allowance an owner has granted to a spender, in base units.
Returns: number
Syntax
Section titled “Syntax”@token:allowance(tokenSymbol owner spender)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
tokenSymbol | token-symbol | Token symbol (e.g. DAI) or address |
owner | address | Owner address |
spender | address | Spender address |
Examples
Section titled “Examples”# Query an allowanceset $allowance @token:allowance(DAI @me 0x4F2083f5fBede34C2714aFfb3105539775f7FE64)
# Top up an allowance only when it is too lowset $spender 0x4F2083f5fBede34C2714aFfb3105539775f7FE64if @bool(@token:allowance(DAI @me $spender) < @token:amount(DAI 100)) ( token:approve @token:amount(DAI 100) @token(DAI) for $spender)See Also
Section titled “See Also”- @token:balance — token balance of an address
- @token:amount — convert to base units
- token:approve — grant an allowance