Skip to Content
GuidesRead rights over the EVM

Read rights over the EVM

Every right kind is an ERC-20 (an AE-20) at a derived address. This guide reads the investor’s ECONOMIC units of $ASSET two ways — natively and over Ethereum JSON-RPC — and gets the same number.

export AEVA_EVM=${AEVA_EVM:-https://evm.aevachain.com} rpc() { curl -sf -X POST -H 'content-type: application/json' -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"$1\",\"params\":$2}" "$AEVA_EVM" | jq -r .result; } echo "chain id: $(rpc eth_chainId '[]')"
Expected output
chain id: 0x94e

0x94e is 2382, the EVM chain id of every Aeva network.

1. The addresses

TOKEN=$(aevad query erc20rights tokens "$ASSET" --node "$AEVA_NODE" -o json | jq -r '.tokens[] | select((.kind_id // 0 | tonumber) == 0) | .address') INVESTOR_HEX=$(aevad debug addr "$INVESTOR" | awk '/Address hex/ {print $3}') echo "ECONOMIC AE-20: $TOKEN" echo "investor: $INVESTOR = $INVESTOR_HEX"

aevad debug addr converts between the two forms of one account; they are the same 20 bytes.

2. balanceOf, natively and over the EVM

DATA="0x70a08231000000000000000000000000$(tr 'A-F' 'a-f' <<<"${INVESTOR_HEX#0x}")" EVM_BAL=$(rpc eth_call "[{\"to\":\"$TOKEN\",\"data\":\"$DATA\"},\"latest\"]") echo "EVM balanceOf: $((EVM_BAL))" aevad query rights position "$ASSET" 0 "$INVESTOR" --node "$AEVA_NODE" -o json | jq -r '"native transferable: \((.position.units | tonumber) - (.position.encumbered // "0" | tonumber))"'

balanceOf returns transferable units — held minus locked — so a pledge or a pending settlement lowers it. To transfer through the EVM, send transfer(to, amount) to the same address from MetaMask or any Ethereum library; the native policy applies and a refusal reverts with aeva: policy denied: <rule path>. See The EVM facade & AE-20.

Last updated