I am trying to interact with an erc20 token (contains proxies) using geth.
Environment
Geth/v1.9.24
Details
This is the process I follow when interacting with a regular erc20 token without proxies (ex. usdt):
- Create a .js file similar to below:
var usdtContractToken = eth.contract([{…usdtABI…}])
var usdtContractAddress = “0xdAC17F958D2ee523a2206206994597C13D831ec7”;
var usdt = usdtContractToken.at(usdtContractAddress);
- Preload geth with the above .js file using command:
geth attach --preload < pathToJsFile >
- Then interact with the erc20 token in geth console:
I am facing difficulties with using the above methodology when interacting with erc20 tokens that involve proxy contracts (ex. usdc, which uses OpenZeppelin’s Unstructured Storage proxy pattern).
I am not sure what are the additional steps required to configure this setup.
Below is the .js file I am using to preload into geth:
Code to reproduce
// proxy
var usdcProxyContractToken = eth.contract([{…usdcProxyABI…}]);
var usdcProxyContractAddress = “0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48”;
var usdcProxy = usdcProxyContractToken.at(usdcProxyContractAddress);// implementation
var usdcImpContractToken = eth.contract([{…usdcImpABI…}]);
var usdcImpContractAddress = “0xB7277a6e95992041568D9391D09d0122023778A2”;
var usdcImp = usdcImpContractToken.at(usdcImpContractAddress);
Output from geth console:
usdcProxy.admin()
Error: execution reverted
at web3.js:6347:37(47)
at web3.js:5081:62(37)
at web3.js:4102:36(54)
at web3.js:4227:60(38)
at :1:1(2)
usdcImp.name()
Error: invalid address
at web3.js:3930:11(47)
at web3.js:3756:41(16)
at web3.js:5025:37(8)
at web3.js:5024:12(13)
at web3.js:5050:34(20)
at web3.js:5075:39(15)
at web3.js:4137:41(57)
at web3.js:4223:75(24)
at :1:1(2)