Building Batched Streams in Safe
If you have a Safe and are looking to send multiple streams in one transaction rather than having to manually execute each one, this guide will show you how it's done.
1. Go to the Safe Transaction Builder
Safe Transaction Builder Interface
2. Get CFAv1Forwarder Address
Find the CFAv1Forwarder address for the desired network below:
Network | Address |
---|---|
Ethereum Mainnet, Polygon, Gnosis Chain, Optimism, Arbitrum, Avalanche, BNB Chain, Goerli, Arbitrum Goerli, Optimism Goerli, Mumbai | 0xcfA132E353cB4E398080B9700609bb008eceB125 |
Avalanche Fuji | 0x2CDd45c5182602a36d391F7F16DD9f8386C3bD8D |
Paste that address in the Enter Address or ENS Name box on the Transaction Builder interface.
3. Copy CFAv1Forwarder ABI
Copy the ABI below and paste it in the Enter ABI box in the Transaction Builder interface.
Expand for CFAv1Forwarder ABI
[
{
"inputs": [
{
"internalType": "contract ISuperfluid",
"name": "host",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "CFA_FWD_INVALID_FLOW_RATE",
"type": "error"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
},
{
"internalType": "bytes",
"name": "userData",
"type": "bytes"
}
],
"name": "createFlow",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "bytes",
"name": "userData",
"type": "bytes"
}
],
"name": "deleteFlow",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "getAccountFlowInfo",
"outputs": [
{
"internalType": "uint256",
"name": "lastUpdated",
"type": "uint256"
},
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
},
{
"internalType": "uint256",
"name": "deposit",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "owedDeposit",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "getAccountFlowrate",
"outputs": [
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
}
],
"name": "getBufferAmountByFlowrate",
"outputs": [
{
"internalType": "uint256",
"name": "bufferAmount",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "getFlowInfo",
"outputs": [
{
"internalType": "uint256",
"name": "lastUpdated",
"type": "uint256"
},
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
},
{
"internalType": "uint256",
"name": "deposit",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "owedDeposit",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "flowOperator",
"type": "address"
}
],
"name": "getFlowOperatorPermissions",
"outputs": [
{
"internalType": "uint8",
"name": "permissions",
"type": "uint8"
},
{
"internalType": "int96",
"name": "flowrateAllowance",
"type": "int96"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "getFlowrate",
"outputs": [
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "flowOperator",
"type": "address"
}
],
"name": "grantPermissions",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "flowOperator",
"type": "address"
}
],
"name": "revokePermissions",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
}
],
"name": "setFlowrate",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
}
],
"name": "setFlowrateFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "int96",
"name": "flowrate",
"type": "int96"
},
{
"internalType": "bytes",
"name": "userData",
"type": "bytes"
}
],
"name": "updateFlow",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "flowOperator",
"type": "address"
},
{
"internalType": "uint8",
"name": "permissions",
"type": "uint8"
},
{
"internalType": "int96",
"name": "flowrateAllowance",
"type": "int96"
}
],
"name": "updateFlowOperatorPermissions",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
4. Line Up Streaming Transactions
Now you'll be able to set up each stream transaction for the batch one at a time. If you're looking to create streams, select the createFlow
method.
Interface for setting up streaming transactions
Function Parameters
token (address)
: Super Token you're streamingsender (address)
: Your Safe addressreceiver (address)
: The receiver's addressflowrate (int96)
: Flow rate in secondsuserData (bytes)
: Enter0x
.
Hit Add Transaction
and repeat for each stream you'd like to send.
Flow Rate is always in wei/second. Super Tokens always have 18 decimals of precision.
For example, to stream 1000 DAIx/month to Alice:
flowrate
= 1,000 _ (10^18) / ( seconds in month ) = 1,000 _ (10^18) / 2628000 = 380517503805175
5. Create and Send the Batch
Once you've added all operations to the batch, click "Create Batch" and then "Send Batch". After execution, your streams should be running.
You can check out the Superfluid Safe App to see the streams in action and conduct necessary modifications.