Developers
Search…
Encoding userData
There are some arguments that need to be encoded when interacting with Balancer V2 Smart Contracts. For convenience, this page provides an example of how to encode arguments.
Solidity
js
Python
1
uint256 JoinKindInit = 0;
2
uint256 initBalances[] = [1e18, 2e18];
3
bytes userDataEncoded = abi.encode(JoinKindInit, initBalances);
Copied!
1
import { defaultAbiCoder } from '@ethersproject/abi';
2
3
const JoinKindInit = 0;
4
const initBalances = [1e18, 2e18];
5
const abi = ['uint256', 'uint256[]'];
6
const data = [JoinKindInit, initBalances];
7
const userDataEncoded = defaultAbiCoder.encode(abi,data);
Copied!
1
import eth_abi
2
3
JoinKindInit = 0
4
initBalances = [1e18, 2e18]
5
abi = ['uint256', 'uint256[]']
6
data = [JoinKindInit, initBalances]
7
userDataEncoded = eth_abi.encode_abi(abi, data)
Copied!
Last modified 2mo ago
Copy link