Curl not working properly for Erc20, Erc721
Closed this issue · 1 comments
longtruongg commented
Detailed Description
hi, I was trying to check balanceOf using :
https://localhost:9200/v1/vault-ethereum/accounts/bob/erc20/balanceOf
Its giving me error: :
"errors": [
"1 error occurred:\n\t* no contract code at given address\n\n"
]
But when i was using Vault command :
vault read -format=json vault-ethereum/accounts/bob/erc20/balanceOf contract='0x337610d27c682E347C9cD60BD4b3b107C9d34dDd'
got data
{
"request_id": "76020c80-38b5-dc20-3362-39358f5a6176",
"lease_id": "",
"lease_duration": 0,
"renewable": false,
"data": {
"balance": "1",
"contract": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
"name": "USDT Token",
"symbol": "USDT"
},
"warnings": null
}
Context
I got an error when calling erc20 / balanceOf API using curl / post man, but when I call with Vault command get the data, I also want to get the same data using postman / curl
Your Environment
- OS: Debian 11
- VAULT_VERSION :1.9.2
cypherhat commented
The vault CLI has an option to output a curl command. For example:
vault read -output-curl-string -format=json vault-ethereum/accounts/bob/erc20/totalSupply contract="0x863820337f08370a01bCE27Ae1F5CdD7704fd38a"
curl -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" https://localhost:9200/v1/vault-ethereum/accounts/bob/erc20/totalSupply?contract=0x863820337f08370a01bCE27Ae1F5CdD7704fd38a
Then, you can (adding the -s
option to curl
)
$ curl -s -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" https://localhost:9200/v1/vault-ethereum/accounts/bob/erc20/totalSupply\?contract\=0x863820337f08370a01bCE27Ae1F5CdD7704fd38a | jq .
{
"request_id": "0e83ddac-fe8a-1077-16fe-6355f778f062",
"lease_id": "",
"renewable": false,
"lease_duration": 0,
"data": {
"contract": "0x863820337f08370a01bCE27Ae1F5CdD7704fd38a",
"name": "Example Fixed Supply Token",
"symbol": "FIXED",
"total_supply": "1000000"
},
"wrap_info": null,
"warnings": null,
"auth": null
}