Developers
Search…
Welcome
Guides
Swaps
Data
Guided Tour of Balancer Vault
Resources
Deploy Pools from Factory
Pool Interfacing
Pool Math
Query: How Much X for Y?
Joins and Exits
Swaps
Internal User Balances
Smart Order Router
Flash Loans
Rate Providers
veBAL and Gauges
Helpers
Using Native ETH
Encoding userData
References
Contracts
Error Codes
Subgraphs
Github
Powered By
GitBook
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!
Helpers - Previous
Using Native ETH
Next - References
Contracts
Last modified
7mo ago
Copy link