How to Get the Latest Axie Spawns
If you think GameFi is dead, think again. The hype and money may have been drained from GameFi today, but the novelty of the mechanics remains. Specifically, Axie Inifinity’s P2E model and its popularity testify to the viability of this unique brand of in-game tokenomics. (If you’re unfamiliar with how it works, check out the GameFi e-book we’ve published last year!) In this article, I’ll be showing you how you can use the GoldRush API to get the data of interesting in-game actions. Specifically, we’ll build a table of the latest Axie spawns that have occurred on the Ronin chain.
Ready? Let’s get started!
Prerequisites
Basic familiarity with React.
Some HTML/CSS knowledge.
Fetching data using APIs.
Tutorial: How to Get Axie Spawn Data
1
Identify the on-chain event you’re interested in
AxieSpawn
is emitted from the transaction. This information is available on the Ronin block explorer, for instance in this transaction:topic[0]
is the topic hash that we can use to search for this event (0xb6fa90c3cb274eb5fe963b2deb623847e804c9d2b0791bee8e9883320f404a5d), topic[1]
tells us what the Axie ID is.2
Get the data of all AxieSpawn events
starting-block
: the starting block to query for: 23581942 in this case. The Get logs endpoint currently supports a 2000 block range.ending-block
: ‘latest’ will get you the latest block. Can also specify a block number.topics
: 0xb6fa90c3cb274eb5fe963b2deb623847e804c9d2b0791bee8e9883320f404a5d{API_KEY}
: You can replace the<API_KEY>
with your own GoldRush API key and give it a call in your preferred environment. In the production environment, it’s best to supply the API key in the request header with Basic Auth.
{
"data": {
"updated_at": "2023-04-28T08:02:35.703133077Z",
"chain_id": 2020,
"chain_name": "axie-mainnet",
"items": [
{
"block_signed_at": "2023-04-28T07:48:49Z",
"block_height": 23614350,
"block_hash": "0x0ae8e7880d83b001df1673e892e5fdf5d8c2a68c3e29f1bd9195186ffe9ed0af",
"tx_offset": 1,
"log_offset": 20,
"tx_hash": "0x1ad6879026b04b27788e1902d05bda0b202ebb19338770b0146b7dfce35b0190",
"raw_log_topics": [
"0xb6fa90c3cb274eb5fe963b2deb623847e804c9d2b0791bee8e9883320f404a5d",
"0x0000000000000000000000000000000000000000000000000000000000b2c861"
],
"sender_contract_decimals": 0,
"sender_name": "Axie",
"sender_contract_ticker_symbol": "AXIE",
"sender_address": "0x32950db2a7164ae833121501c797d79e7b79d74c",
"sender_address_label": null,
"sender_logo_url": "<https://logos.covalenthq.com/tokens/2020/0x32950db2a7164ae833121501c797d79e7b79d74c.png>",
"raw_log_data": null,
"decoded": null
},
{
"block_signed_at": "2023-04-28T07:49:49Z",
"block_height": 23614370,
"block_hash": "0x0709060d5b712cab57d708e37d84d977814f5cbd9cf28c8cd66b41df5e467180",
"tx_offset": 0,
"log_offset": 5,
"tx_hash": "0x7416d55904fba32ecc75aaa518756ed7a55bb7994e8fbdef8716c65640322266",
"raw_log_topics": [
"0xb6fa90c3cb274eb5fe963b2deb623847e804c9d2b0791bee8e9883320f404a5d",
"0x0000000000000000000000000000000000000000000000000000000000b2c862"
],
"sender_contract_decimals": 0,
"sender_name": "Axie",
"sender_contract_ticker_symbol": "AXIE",
"sender_address": "0x32950db2a7164ae833121501c797d79e7b79d74c",
"sender_address_label": null,
"sender_logo_url": "<https://logos.covalenthq.com/tokens/2020/0x32950db2a7164ae833121501c797d79e7b79d74c.png>",
"raw_log_data": null,
"decoded": null
},
{
"block_signed_at": "2023-04-28T07:55:37Z",
"block_height": 23614486,
"block_hash": "0xd4656681b3369e92eba7af3f3a330187d7fec8363dcae9590c43b16b76db30d7",
"tx_offset": 1,
"log_offset": 8,
"tx_hash": "0x8bf924ed835707c5f8675f2e1976c81a2d956371a28b720982bb3aaaddbbeab2",
"raw_log_topics": [
"0xb6fa90c3cb274eb5fe963b2deb623847e804c9d2b0791bee8e9883320f404a5d",
"0x0000000000000000000000000000000000000000000000000000000000b2c863"
],
"sender_contract_decimals": 0,
"sender_name": "Axie",
"sender_contract_ticker_symbol": "AXIE",
"sender_address": "0x32950db2a7164ae833121501c797d79e7b79d74c",
"sender_address_label": null,
"sender_logo_url": "<https://logos.covalenthq.com/tokens/2020/0x32950db2a7164ae833121501c797d79e7b79d74c.png>",
"raw_log_data": null,
"decoded": null
}
...
],
"pagination": null
},
"error": false,
"error_message": null,
"error_code": null
}
- the second item of the
raw_log_topics
array tells us the Axie ID. It is in hexadecimal so we’ll have to convert it to decimals to display. - the
tx_hash
tells us the transaction that emitted this event. block_signed_at
tells us the date and time this event is emitted.
tx_hash
we have and make further calls using GoldRush’s Get a transaction endpoint.3
Getting more data for each Axie spawn
https://api.covalenthq.com/v1/axie-mainnet/transaction_v2/0x1ad6879026b04b27788e1902d05bda0b202ebb19338770b0146b7dfce35b0190/?key={API_KEY}
tx_hash
of the first item from our response earlier.{
"data": {
"updated_at": "2023-04-28T08:25:42.900771069Z",
"chain_id": 2020,
"chain_name": "axie-mainnet",
"items": [
{
"block_signed_at": "2023-04-28T07:48:49Z",
"block_height": 23614350,
"tx_hash": "0x1ad6879026b04b27788e1902d05bda0b202ebb19338770b0146b7dfce35b0190",
"tx_offset": 1,
"successful": true,
"from_address": "0xb1e6a87f71564d15cdba14546d0462f8b9787ed7",
"from_address_label": null,
"to_address": "0x32950db2a7164ae833121501c797d79e7b79d74c",
"to_address_label": null,
"value": "0",
"value_quote": null,
"gas_offered": 437659,
"gas_spent": 431230,
"gas_price": 20000000000,
"fees_paid": "8624600000000000",
"gas_quote": null,
"gas_quote_rate": null,
"log_events": [
...
{
"block_signed_at": "2023-04-28T07:48:49Z",
"block_height": 23614350,
"tx_offset": 1,
"log_offset": 18,
"tx_hash": "0x1ad6879026b04b27788e1902d05bda0b202ebb19338770b0146b7dfce35b0190",
"raw_log_topics": [
"0xd145ab8597dad93dd168121d96688fa7d06040c6bcffcfda8b8d24b1669e8478",
"0x0000000000000000000000000000000000000000000000000000000000b1cf6e",
"0x0000000000000000000000000000000000000000000000000000000000000001"
],
"sender_contract_decimals": 0,
"sender_name": "Axie",
"sender_contract_ticker_symbol": "AXIE",
"sender_address": "0x32950db2a7164ae833121501c797d79e7b79d74c",
"sender_address_label": null,
"sender_logo_url": "<https://logos.covalenthq.com/tokens/2020/0x32950db2a7164ae833121501c797d79e7b79d74c.png>",
"raw_log_data": null,
"decoded": null
},
{
"block_signed_at": "2023-04-28T07:48:49Z",
"block_height": 23614350,
"tx_offset": 1,
"log_offset": 16,
"tx_hash": "0x1ad6879026b04b27788e1902d05bda0b202ebb19338770b0146b7dfce35b0190",
"raw_log_topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000b1e6a87f71564d15cdba14546d0462f8b9787ed7",
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
"sender_contract_decimals": 0,
"sender_name": "Smooth Love Potion",
"sender_contract_ticker_symbol": "SLP",
"sender_address": "0xa8754b9fa15fc18bb59458815510e40a12cd2014",
"sender_address_label": null,
"sender_logo_url": "<https://logos.covalenthq.com/tokens/2020/0xa8754b9fa15fc18bb59458815510e40a12cd2014.png>",
"raw_log_data": "0x0000000000000000000000000000000000000000000000000000000000000708",
"decoded": {
"name": "Transfer",
"signature": "Transfer(indexed address from, indexed address to, uint256 value)",
"params": [
{
"name": "from",
"type": "address",
"indexed": true,
"decoded": true,
"value": "0xb1e6a87f71564d15cdba14546d0462f8b9787ed7"
},
{
"name": "to",
"type": "address",
"indexed": true,
"decoded": true,
"value": "0x0000000000000000000000000000000000000000"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"decoded": true,
"value": "1800"
}
]
}
},
{
"block_signed_at": "2023-04-28T07:48:49Z",
"block_height": 23614350,
"tx_offset": 1,
"log_offset": 15,
"tx_hash": "0x1ad6879026b04b27788e1902d05bda0b202ebb19338770b0146b7dfce35b0190",
"raw_log_topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000b1e6a87f71564d15cdba14546d0462f8b9787ed7",
"0x000000000000000000000000a99cacd1427f493a95b585a5c7989a08c86a616b"
],
"sender_contract_decimals": 18,
"sender_name": "Axie Infinity Shard",
"sender_contract_ticker_symbol": "AXS",
"sender_address": "0x97a9107c1793bc407d6f527b77e7fff4d812bece",
"sender_address_label": null,
"sender_logo_url": "<https://logos.covalenthq.com/tokens/2020/0x97a9107c1793bc407d6f527b77e7fff4d812bece.png>",
"raw_log_data": "0x00000000000000000000000000000000000000000000000006f05b59d3b20000",
"decoded": {
"name": "Transfer",
"signature": "Transfer(indexed address from, indexed address to, uint256 value)",
"params": [
{
"name": "from",
"type": "address",
"indexed": true,
"decoded": true,
"value": "0xb1e6a87f71564d15cdba14546d0462f8b9787ed7"
},
{
"name": "to",
"type": "address",
"indexed": true,
"decoded": true,
"value": "0xa99cacd1427f493a95b585a5c7989a08c86a616b"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"decoded": true,
"value": "500000000000000000"
}
]
}
}
]
}
],
"pagination": null
},
"error": false,
"error_message": null,
"error_code": null
}
log_events
field, we have a lot more raw data to work with. In particular, we have information on how much SLP and AXS tokens are transferred.0xd145ab8597dad93dd168121d96688fa7d06040c6bcffcfda8b8d24b1669e8478
. This insight is derived from cross-referencing Ronin explorer to find the matching topic hash:4
Initialize the project
App.js
and /components/AxieRow.js
. Everything is styled with App.css
.<AxieRow />
component.5
Fetch the data
App.js
using the Get Logs endpoint, and then use the tx_hash
returned to fetch additional data of each transaction using Get a transaction endpoint.starting-block
to fetch for our Get logs endpoint later..env
file in the project root and add your API key, like so:REACT_APP_APIKEY='ckey_8bdxxxxxxxxxxxxxxxxxxxxxxxxxx99'
?starting-block=${Number(latestBlock)-latestBlocksToFetch}
.tx_hash
into the AxieRow component:<AxieRow />
component, define the getTxEndpoint
using our tx_hash
prop, and fetch the data:npm start
, you should be able to see the following in the dev console:6
Supply it as props to our components
<AxieRow />
component with our live data to render the component. Here’s what it looks like (with some data cleaning involved):npm start
:All in a day’s work
Congratulations. You’ve successfully managed to build a react component that gets live on-chain data from the Ronin chain of an important Axie in-game event. Hopefully, you’ll be able to see the process of how that’s done with the GoldRush API, and tried it yourself. The concepts illustrated in this guide can also be applied to analyze other kinds of in-game events, provided you know the topic hash of the event emitted - making this a very powerful tool for diving deep into GameFi on-chain actions.