You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensures a fixed ERC-20 token allowance.
Transfers are allowed until the total transferred amount reaches the allowance amount.
Parameters
Name
Type
Required
Description
tokenAddress
Address
Yes
The ERC-20 token contract address.
allowanceAmount
bigint
Yes
The maximum total amount of tokens that can be transferred.
startTime
number
No
The start timestamp in seconds. The default is the current time.
justification
string
No
A human-readable explanation of why the permission is being requested.
Example
import{parseUnits}from'viem'constcurrentTime=Math.floor(Date.now()/1000)constexpiry=currentTime+604800constpermission={type: 'erc20-token-allowance',data: {tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',allowanceAmount: parseUnits('50',6),startTime: currentTime,justification: 'Permission to transfer up to 50 USDC in total',},isAdjustmentAllowed: true,}
ERC-20 periodic permission
Ensures a per-period limit for ERC-20 token transfers.
At the start of each new period, the allowance resets.
Parameters
Name
Type
Required
Description
tokenAddress
Address
Yes
The ERC-20 token contract address as a hex string.
periodAmount
bigint
Yes
The maximum amount of tokens that can be transferred per period.
periodDuration
number
Yes
The duration of each period in seconds.
startTime
number
No
The start timestamp in seconds. The default is the current time.
justification
string
No
A human-readable explanation of why the permission is being requested.
Example
import{parseUnits}from'viem'constcurrentTime=Math.floor(Date.now()/1000)constexpiry=currentTime+604800constpermission={type: 'erc20-token-periodic',data: {tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',periodAmount: parseUnits('10',6),periodDuration: 86400,justification: 'Permission to transfer 10 USDC every day',},isAdjustmentAllowed: true,}
ERC-20 stream permission
Ensures a linear streaming transfer limit for ERC-20 tokens.
Token transfers are blocked until the defined start timestamp.
At the start, a specified initial amount is released, after which tokens accrue linearly at the configured rate, up to the maximum allowed amount.
Parameters
Name
Type
Required
Description
tokenAddress
Address
Yes
The ERC-20 token contract address.
initialAmount
bigint
No
The initial amount that can be transferred at start time. The default is 0.
maxAmount
bigint
No
The maximum total amount that can be unlocked. The default is no limit.
amountPerSecond
bigint
Yes
The rate at which tokens accrue per second.
startTime
number
No
The start timestamp in seconds. The default is the current time.
justification
string
No
A human-readable explanation of why the permission is being requested.
Example
import{parseUnits}from'viem'constcurrentTime=Math.floor(Date.now()/1000)constexpiry=currentTime+604800constpermission={type: 'erc20-token-stream',data: {tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',amountPerSecond: parseUnits('0.1',6),initialAmount: parseUnits('1',6),maxAmount: parseUnits('2',6),startTime: currentTime,justification: 'Permission to use 0.1 USDC per second',},isAdjustmentAllowed: true,}
Native token permissions
Native token allowance permission
Ensures a fixed native token allowance.
Transfers are allowed until the total transferred amount reaches the allowance amount.
Parameters
Name
Type
Required
Description
allowanceAmount
bigint
Yes
The maximum total amount of tokens that can be transferred.
startTime
number
No
The start timestamp in seconds. The default is the current time.
justification
string
No
A human-readable explanation of why the permission is being requested.
Example
import{parseEther}from'viem'constcurrentTime=Math.floor(Date.now()/1000)constexpiry=currentTime+604800constpermission={type: 'native-token-allowance',data: {allowanceAmount: parseEther('0.05'),startTime: currentTime,justification: 'Permission to transfer up to 0.05 ETH in total',},isAdjustmentAllowed: true,}
Native token periodic permission
Ensures a per-period limit for native token transfers.
At the start of each new period, the allowance resets.
Parameters
Name
Type
Required
Description
periodAmount
bigint
Yes
The maximum amount of tokens that can be transferred per period.
periodDuration
number
Yes
The duration of each period in seconds.
startTime
number
No
The start timestamp in seconds. The default is the current time.
justification
string
No
A human-readable explanation of why the permission is being requested.
Example
import{parseEther}from'viem'constcurrentTime=Math.floor(Date.now()/1000)constexpiry=currentTime+604800constpermission={type: 'native-token-periodic',data: {periodAmount: parseEther('0.001'),periodDuration: 86400,startTime: currentTime,justification: 'Permission to use 0.001 ETH every day',},isAdjustmentAllowed: true,}
Native token stream permission
Ensures a linear streaming transfer limit for native tokens.
Token transfers are blocked until the defined start timestamp.
At the start, a specified initial amount is released, after which tokens accrue linearly at the configured rate, up to the maximum allowed amount.
Parameters
Name
Type
Required
Description
initialAmount
bigint
No
The initial amount that can be transferred at start time. The default is 0.
maxAmount
bigint
No
The maximum total amount that can be unlocked. The default is no limit.
amountPerSecond
bigint
Yes
The rate at which tokens accrue per second.
startTime
number
No
The start timestamp in seconds. The default is the current time.
justification
string
No
A human-readable explanation of why the permission is being requested.
Example
import{parseEther}from'viem'constcurrentTime=Math.floor(Date.now()/1000)constexpiry=currentTime+604800constpermission={type: 'native-token-stream',data: {amountPerSecond: parseEther('0.0001'),initialAmount: parseEther('0.1'),maxAmount: parseEther('1'),startTime: currentTime,justification: 'Permission to use 0.0001 ETH per second',},isAdjustmentAllowed: true,}