Test hummingbot gateway API with xdc chain
- Setup enviroment according to instruction before test.
- Mint some test tokens to your test account.
# curl -s -X GET -k --key ${GATEWAY_KEY} --cert ${GATEWAY_CERT} ${SERVER} | jq
https --print=b ${SERVER}
# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/config" | jq
https --print=b ${SERVER}/network/config
# curl -s -X GET -k --key ${GATEWAY_KEY} --cert ${GATEWAY_CERT} ${SERVER}/connectors | jq
https --print=b ${SERVER}/connectors
xinfin
# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/status?chain=xdc&network=xinfin" | jq
https --print=b ${SERVER}/network/status chain==xdc network==xinfin
apothem
# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/status?chain=xdc&network=apothem" | jq
https --print=b ${SERVER}/network/status chain==xdc network==apothem
all networks
# curl -s -X GET -k --key $GATEWAY_KEY --cert "$GATEWAY_CERT" "${SERVER}/network/status" | jq
https --print=b ${SERVER}/network/status
xinfin
# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/tokens?chain=xdc&network=xinfin" | jq
https --print=b ${SERVER}/network/tokens chain==xdc network==xinfin
apothem
# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/tokens?chain=xdc&network=apothem" | jq
https --print=b ${SERVER}/network/tokens chain==xdc network==apothem
xinfin
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/network/poll" -d '{
"chain": "xdc",
"network": "xinfin",
"txHash": "0xf49e741720e3f6c464e7bfbdcaefddb6f9a4cc39d4b367476727e95be735b350"
}' | jq
apothem
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/network/poll" -d '{
"chain": "xdc",
"network": "apothem",
"txHash": "0x1114601d48ebc3afa5e06af13e759560e74b3d5d1837d951919bc57727a623dd"
}' | jq
xinfin
https --print=b POST ${SERVER}/network/poll chain=xdc network=xinfin txHash=0xf49e741720e3f6c464e7bfbdcaefddb6f9a4cc39d4b367476727e95be735b350
apothem
https --print=b POST ${SERVER}/network/poll chain=xdc network=apothem txHash=0x1114601d48ebc3afa5e06af13e759560e74b3d5d1837d951919bc57727a623dd
The length of private key is 67 characters with xdc
prefix or 66 characters with 0x
prefix, such as:
- xdc prefix: xdc0123456789012345678901234567890123456789012345678901234567890123
- 0x prefix: 0x0123456789012345678901234567890123456789012345678901234567890123
We will use xdc-prefix in below tests.
# export XDC_PRIVATE_KEY="xdc0123456789012345678901234567890123456789012345678901234567890123"
export XDC_PRIVATE_KEY="<YOUR_XDC_PRIVATE_KEY>"
xinfin
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/wallet/add" -d '{
"privateKey": "'"${XDC_PRIVATE_KEY}"'",
"chain": "xdc",
"network":"xinfin"
}' | jq
apothem
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/wallet/add" -d '{
"privateKey": "'"${XDC_PRIVATE_KEY}"'",
"chain": "xdc",
"network":"apothem"
}' | jq
xinfin
https --print=b ${SERVER}/wallet/add privateKey=${XDC_PRIVATE_KEY} chain=xdc network=xinfin
apothem
https --print=b ${SERVER}/wallet/add privateKey=${XDC_PRIVATE_KEY} chain=xdc network=apothem
xinfin
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/network/balances" -d '{
"chain": "xdc",
"network": "xinfin",
"address": "'"${XDC_ADDRESS}"'",
"tokenSymbols": ["XDC","WXDC"]
}' | jq
apothem
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/network/balances" -d '{
"chain": "xdc",
"network": "apothem",
"address": "'"${XDC_ADDRESS}"'",
"tokenSymbols": ["XDC","WXDC", "DAI", "WBTC2", "YFI2", "MKR2", "AAVE2", "UNI2", "USDC2"]
}' | jq
xinfin
https --print=b POST ${SERVER}/network/balances chain=xdc network=xinfin \
address=${XDC_ADDRESS} tokenSymbols:='["XDC", "WXDC"]'
apothem
https --print=b POST ${SERVER}/network/balances chain=xdc network=apothem \
address=${XDC_ADDRESS} tokenSymbols:='["XDC", "WXDC", "WBTC2", "YFI2", "MKR2", "USDC2"]'
xinfin
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/nonce" -d '{
"chain": "xdc",
"network": "xinfin",
"address":"'"$XDC_ADDRESS"'"
}' | jq
apothem
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/nonce" -d '{
"chain": "xdc",
"network": "apothem",
"address":"'"$XDC_ADDRESS"'"
}' | jq
xinfin
https --print=b POST ${SERVER}/evm/nonce chain=xdc network=xinfin address=${XDC_ADDRESS}
apothem
https --print=b POST ${SERVER}/evm/nonce chain=xdc network=apothem address=${XDC_ADDRESS}
xinfin
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/allowances" -d '{
"chain": "xdc",
"network": "xinfin",
"address": "'"$XDC_ADDRESS"'",
"spender": "xdc41c0ad06c98951e9bf7172cd1d285c6e34537170",
"tokenSymbols": ["WXDC", "SRX", "XTT", "xUSDT"]
}' | jq
apothem
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/allowances" -d '{
"chain": "xdc",
"network": "apothem",
"address": "'"$XDC_ADDRESS"'",
"spender": "xdc41c0ad06c98951e9bf7172cd1d285c6e34537170",
"tokenSymbols": ["WBTC2", "YFI2", "MKR2", "AAVE2", "UNI2", "USDC2"]
}' | jq
xinfin
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=xinfin address=${XDC_ADDRESS} \
spender=xdc85f33E1242d87a875301312BD4EbaEe8876517BA tokenSymbols:='["WXDC", "SRX", "XTT", "xUSDT"]'
apothem
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc85f33E1242d87a875301312BD4EbaEe8876517BA tokenSymbols:='["WBTC2", "YFI2", "MKR2", "AAVE2", "UNI2", "USDC2"]'
xinfin
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/approve" -d '{
"chain": "xdc",
"network": "xinfin",
"address": "'"$XDC_ADDRESS"'",
"spender": "xdc41c0ad06c98951e9bf7172cd1d285c6e34537170",
"token": "SRX"
}' | jq
apothem
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/approve" -d '{
"chain": "xdc",
"network": "apothem",
"address": "'"$XDC_ADDRESS"'",
"spender": "xdc41c0ad06c98951e9bf7172cd1d285c6e34537170",
"token": "USDC2"
}' | jq
xinfin
# query allowances
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=xinfin address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 tokenSymbols:='["SRX"]'
# set allowances to maximum
https --print=h POST ${SERVER}/evm/approve chain=xdc network=xinfin address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 token=SRX
# query allowances
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=xinfin address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 tokenSymbols:='["SRX"]'
apothem
# clear allowances
https --print=h POST ${SERVER}/evm/approve chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 token=USDC2 amount=0
# query allowances
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 tokenSymbols:='["USDC2"]'
# set allowances to maximum
https --print=h POST ${SERVER}/evm/approve chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 token=USDC2
# query allowances
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 tokenSymbols:='["USDC2"]'