Created
September 17, 2020 18:26
-
-
Save dvush/cf8b0e511be70a9f172a43cd2afb8d8f to your computer and use it in GitHub Desktop.
Get balance on contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getBalanceOnContract(ethSigner: ethers.Signer, zksyncProvider: zksync.Provider, token: zksync.types.TokenLike) { | |
const tokenId = zksyncProvider.tokenSet.resolveTokenId(token); | |
const ABI = [{ | |
"constant": true, | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint16", | |
"name": "_tokenId", | |
"type": "uint16" | |
} | |
], | |
"name": "getBalanceToWithdraw", | |
"outputs": [ | |
{ | |
"internalType": "uint128", | |
"name": "", | |
"type": "uint128" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}] | |
const zksContract = new ethers.Contract(zksyncProvider.contractAddress.mainContract, ABI, ethSigner.provider); | |
return await zksContract.getBalanceToWithdraw(await ethSigner.getAddress(), tokenId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0x643e8237b1c9a27711dbb39708b7bf1cd136b32e