Quest System
The Quest System is a nodejs server written in typescript and uses sqlite as its backend database. The indexer has three main components:
- Quest Indexer: identify when a specific
questdefined by filter criteria has been completed on chain - Quest Rewarder: transfer an FA2 token to the user who has completed the quest
- API: provide an API server for Apps to query and get live information
Quest Criteria
The Quest Indexer runs by scanning each block on chain. It used the rpc endpoint chains/main/blocks/${block_level} to get all the block data. The indexer uses the envioronment variables to determine:
- BLOCK_START: block to start indexing
- BLOCK_END: block to stop indexing
- RPC_ENDPOINT: base url for the
RPCnode - CHAIN_ID: chain_id to match for the
RPCnode - POLLING_FREQUENCY: how frequently to check for new blocks
The first thing the indexer does is determine the current BlockLevel of the chain. The indexer will then synchronize by its state to the current Head Block. The indexer keeps track of its own state which can seen at the API endpoint status. If the indexer process is ever stopped or killed it will start back from where it left off.
Each block is then iterated through by its operations to identify any Daily Rewards, Quest Completed, and Special Auctions
runs through each block on chain and checks for predefined types of on-chain activity. Run a process on the results which:
- makes a call to a contract to “reward the account which performed the onchain activity
- writes to an off-chain database which accounts were rewarded in order to filter them out of the next query result
Quest Operation Matching
The indexer can iterate through all the operations within a block to see if they match specific criteria. The Criteria is pre-defined with a specific format. The specific criteria for each game can all be seen at in API quests endpoint. The criteria much be defined as JSON in a specific way.
- each property of the operation representated as a string seperated by the
:character - If the operation property is an arrary it becomes flattened into an object
See Block Example for how the JSON of a block looks like when returned from the RPC endpoint
For example: the below criteria will match all operations in a block where the chain_id is NetXm8tYqnMWky1
"operations": [
[
{
...
"chain_id": "NetXm8tYqnMWky1"
...
}
]
]
Below is a sample of possible criteria that can be used:
[
{
name: 'transfer XTZ',
description: 'easy filters to pass; any transaction over 1 XTZ',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:amount': {
eval: 'value >= 1000000'
},
}
},
{
name: 'to-dirauth',
description: 'Use Kukai wallet to send >= x amount of tez to a DirectAuth Kukai account',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:destination': {
eval: 'value.substr(0,3) == "tz2"',
},
'operations:contents:amount': {
eval: 'value >= 1000000'
},
}
},
{
name: 'from-dirauth',
description: 'Use Kukai to send tez from a DirectAuth account to any recipient',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:source': {
eval: 'value.substr(0,3) == "tz2"',
},
'operations:contents:amount': {
eval: 'value >= 1000000'
},
}
},
// https://docs.tezos.domains/deployed-contracts/delphinet
// https://delphinet.tezos.domains/
{
name: 'register-domain',
description: 'Register a domain with Tezos Domains',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:destination': 'KT1Av7mi7s2tm7The7xZGQB5rX5g8sZTNrqN',
'operations:contents:parameters:entrypoint': 'buy',
}
},
{
name: 'send-FA2',
description: 'Send Any FA2 token to a friend',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:destination': {
eval: 'value.substr(0,3) == "KT1"'
},
'operations:contents:parameters:entrypoint': 'transfer',
}
},
{
name: 'send-contrct',
description: 'Send an FA2 token in a defined contract X to any recipient',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:destination': '<KT1...>',
'operations:contents:parameters:entrypoint': 'transfer',
}
},
{
name: 'contrct-to-dauth',
description: 'Send an FA2 token in a defined contract X to a Twitter (DirectAuth) user',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:source': {
eval: 'value.substr(0,3) == "tz2"',
},
'operations:contents:destination': '<KT1...>',
'operations:contents:parameters:entrypoint': 'transfer',
}
},
// https://quipuswap.com/
{
name: 'quipuswap-swap',
description: 'Perform a swap on Quipuswap',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:amount': {
eval: 'value >= 1000000'
},
'operations:contents:destination': {
eval: `[${quipuswap.map(d => `"${d.account}"`)}].includes(value)`
},
'operations:contents:parameters:entrypoint': 'use',
}
},
{
name: 'quipuswap-liquidity',
description: 'Provide liquidity on Quipuswap',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:destination': {
eval: `[${quipuswap.map(d => `"${d.contract}"`)}].includes(value)`
},
'operations:contents:parameters:value:args:string': {
eval: `[${quipuswap.map(d => `"${d.account}"`)}].includes(value)`
},
'operations:contents:parameters:entrypoint': 'approve',
}
},
/* This would be for delphinet */
// https://test.app.dexter.exchange/
{
name: 'dexter-swap',
description: 'Perform a swap on Dexter',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXdQprcVkpaWU',
'operations:contents:kind': 'transaction',
'operations:contents:destination': {
eval: `[${dexterDelphi.map(d => `"${d.account}"`)}].includes(value)`
},
'operations:contents:parameters:entrypoint': {
eval: '["xtzToToken","tokenToXtz","tokenToToken"].includes(value)'
},
}
},
{
name: 'dexter-liquidity',
description: 'Provide liquidity on Dexter',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXdQprcVkpaWU',
'operations:contents:kind': 'transaction',
'operations:contents:amount': {
eval: 'value >= 1000000'
},
'operations:contents:destination': {
eval: `[${dexterDelphi.map(d => `"${d.account}"`)}].includes(value)`
},
'operations:contents:parameters:entrypoint': 'addLiquidity',
}
},
/* This would be for mainnet */
// https://app.dexter.exchange/
// https://better-call.dev/mainnet/KT1DrJV8vhkdLEj76h1H9Q4irZDqAkMPo1Qf/code
{
name: 'dexter-swap',
description: 'Perform a swap on Dexter',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXdQprcVkpaWU',
'operations:contents:kind': 'transaction',
'operations:contents:destination': {
eval: `[${dexter.map(d => `"${d.account}"`)}].includes(value)`
},
'operations:contents:parameters:entrypoint': {
eval: '["xtzToToken","tokenToXtz","tokenToToken"].includes(value)'
},
}
},
{
name: 'dexter-liquidity',
description: 'Provide liquidity on Dexter',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXdQprcVkpaWU',
'operations:contents:kind': 'transaction',
'operations:contents:amount': {
eval: 'value >= 1000000'
},
'operations:contents:destination': {
eval: `[${dexter.map(d => `"${d.account}"`)}].includes(value)`
},
'operations:contents:parameters:entrypoint': 'addLiquidity',
}
},
]
Block 450404
Below is the json returned from the RPC endpoint: chains/main/blocks/450404 on delphinet
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "BLCT2ZMHrxvW3NNMcEF9v3xkdQKSjTcvssA1MBnYcPhsvWMDiH6",
"header": {
"level": 450404,
"proto": 1,
"predecessor": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"timestamp": "2021-02-15T08:03:27Z",
"validation_pass": 4,
"operations_hash": "LLoaC7hY9nwAhrqgH1ekLfyaEzCYJoRRw84hFzAjbspJQWzkt2exq",
"fitness": [
"01",
"000000000006df63"
],
"context": "CoVvRZoE7W8ECfw58rjnP39WBPi3efruxcHfFy2MJeuX9WoLA7ES",
"priority": 0,
"proof_of_work_nonce": "d74e7b6d13820400",
"signature": "sigvpbeBFzgfyyVpyz1RTu5gPmsbTFvf26g5RAk9KM57vT4QtjJ4UTMe53Bqv1cKVSmKZbRcbdNgCgiKNomCNGy1qgZ2MG4t"
},
"metadata": {
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"next_protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"test_chain_status": {
"status": "not_running"
},
"max_operations_ttl": 60,
"max_operation_data_length": 16384,
"max_block_header_length": 238,
"max_operation_list_length": [
{
"max_size": 32768,
"max_op": 32
},
{
"max_size": 32768
},
{
"max_size": 135168,
"max_op": 132
},
{
"max_size": 524288
}
],
"baker": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"level": {
"level": 450404,
"level_position": 450403,
"cycle": 219,
"cycle_position": 1891,
"voting_period": 219,
"voting_period_position": 1891,
"expected_commitment": false
},
"voting_period_kind": "proposal",
"nonce_hash": null,
"consumed_gas": "78671177",
"deactivated": [],
"balance_updates": [
{
"kind": "contract",
"contract": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"change": "-512000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"cycle": 219,
"change": "512000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"cycle": 219,
"change": "38750000"
}
]
},
"operations": [
[
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "ooxhMsUDNcbK8REpJYN5VWfDW8qgajg5X9optptW29Ng5aFdq6G",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz3ZbMfeSAWEYr4AiMJ5Gnamg8Szfr3pv2V2",
"change": "-64000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz3ZbMfeSAWEYr4AiMJ5Gnamg8Szfr3pv2V2",
"cycle": 219,
"change": "64000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz3ZbMfeSAWEYr4AiMJ5Gnamg8Szfr3pv2V2",
"cycle": 219,
"change": "1250000"
}
],
"delegate": "tz3ZbMfeSAWEYr4AiMJ5Gnamg8Szfr3pv2V2",
"slots": [
26
]
}
}
],
"signature": "siguK3wNKomTiA5kLGcFNQp17wt2BKaAKNeCpEqTG8yQtAs3LBC3GMWok23SCyZDaPBiTTVfitU8XSBmLtRovydH5pZtrGEF"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "ooU9iKCbJNcD1b3ZPSgns781io6sC3NCSCoWxLEPsuhFZmtaT3d",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1RUGhq8sQpfGu1W2kf7MixqWX7oxThBFLr",
"change": "-512000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz1RUGhq8sQpfGu1W2kf7MixqWX7oxThBFLr",
"cycle": 219,
"change": "512000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz1RUGhq8sQpfGu1W2kf7MixqWX7oxThBFLr",
"cycle": 219,
"change": "10000000"
}
],
"delegate": "tz1RUGhq8sQpfGu1W2kf7MixqWX7oxThBFLr",
"slots": [
23,
21,
19,
13,
12,
10,
4,
2
]
}
}
],
"signature": "sigqkdYVXngLnhVxBa2WQfYuzyTsWiFuDWpDcodz1DdxkSRXBUVnXpCSdDwj1yaDSxyx3NAphpKSMAYGDMWfQox9f2PMeh8G"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "onreX9cgcLZAoVPW98zQkbFzmVfsG7CQM6SauytHG7R1hiAVZX1",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz3WXYtyDUNL91qfiCJtVUX746QpNv5i5ve5",
"change": "-64000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz3WXYtyDUNL91qfiCJtVUX746QpNv5i5ve5",
"cycle": 219,
"change": "64000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz3WXYtyDUNL91qfiCJtVUX746QpNv5i5ve5",
"cycle": 219,
"change": "1250000"
}
],
"delegate": "tz3WXYtyDUNL91qfiCJtVUX746QpNv5i5ve5",
"slots": [
29
]
}
}
],
"signature": "sigtnGPH4bz7jFobbRxY86iS7Rfn5MJFHEMFcg3huuEPLizY28cLYRc5e45cSJeiDLMFgJwvpHvH366qLECidFGCw6MP84MF"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "ooJh9rPHTYfDgfjna3YRDM2TaTF49vQy3fAgMgS4fxCRwjmhmYz",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1RomaiWJV3NFDZWTMVR2aEeHknsn3iF5Gi",
"change": "-384000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz1RomaiWJV3NFDZWTMVR2aEeHknsn3iF5Gi",
"cycle": 219,
"change": "384000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz1RomaiWJV3NFDZWTMVR2aEeHknsn3iF5Gi",
"cycle": 219,
"change": "7500000"
}
],
"delegate": "tz1RomaiWJV3NFDZWTMVR2aEeHknsn3iF5Gi",
"slots": [
31,
16,
11,
9,
7,
0
]
}
}
],
"signature": "sigvJUuDVGNVMf3VFYMrX7S3akWeDZRKFup37D7tquBdqD3WoCkiCUJPeKUxidKKHtbZSrZnviJVhCAXA2hAByacZQAPaTW2"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "opFXykKkWZf8MViuHfKzbX9vsXkcrB1GEgxh4teLKQ1FxQCpvqb",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1PirboHQVqkYqLSWfHUHEy3AdhYUNJpvGy",
"change": "-64000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz1PirboHQVqkYqLSWfHUHEy3AdhYUNJpvGy",
"cycle": 219,
"change": "64000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz1PirboHQVqkYqLSWfHUHEy3AdhYUNJpvGy",
"cycle": 219,
"change": "1250000"
}
],
"delegate": "tz1PirboHQVqkYqLSWfHUHEy3AdhYUNJpvGy",
"slots": [
3
]
}
}
],
"signature": "sigPcgdgFo3Hu6k7NwNdXPPnwTBggacaT7r3R4aZkHh5FDjLEn9JARjaPHHrqP4vbPgU68eBmsuV46DJs8DxcBM6aurzN4Dq"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "ooAvzM2dxd75k5Vv5o8BqAQYBKbbwxA4oaFaUqFtju6SDHrguUQ",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1T8UYSbVuRm6CdhjvwCfXsKXb4yL9ai9Q3",
"change": "-128000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz1T8UYSbVuRm6CdhjvwCfXsKXb4yL9ai9Q3",
"cycle": 219,
"change": "128000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz1T8UYSbVuRm6CdhjvwCfXsKXb4yL9ai9Q3",
"cycle": 219,
"change": "2500000"
}
],
"delegate": "tz1T8UYSbVuRm6CdhjvwCfXsKXb4yL9ai9Q3",
"slots": [
6,
5
]
}
}
],
"signature": "sigdnEtbTKtHJiamED6sGXBrT2gMsi4hkk2j1PafGSZpRbprGRPnx4Qdubg4vrrcZxPFg9ffs6ZtafY7Qh8AwcEUgxbQrY8t"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "ooe5fcbW1i95w2X3gzZfyZ8oMk4BYjehy4YcXwbiKFPQLteR4np",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1LpmZmB1yJJBcCrBDLSAStmmugGDEghdVv",
"change": "-320000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz1LpmZmB1yJJBcCrBDLSAStmmugGDEghdVv",
"cycle": 219,
"change": "320000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz1LpmZmB1yJJBcCrBDLSAStmmugGDEghdVv",
"cycle": 219,
"change": "6250000"
}
],
"delegate": "tz1LpmZmB1yJJBcCrBDLSAStmmugGDEghdVv",
"slots": [
25,
24,
22,
17,
15
]
}
}
],
"signature": "sigvMAF6BmQQsbLXpX39ctJKfoCt2EJcphC1iETzCbAoyH5o8y6DMryBBw3MDBYMbkGbNehADrz6h4gXwPigUzJfkiXCBPLS"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "onxVRysmSLFUYR1Q9acsEJwLXQxRDizcNzUfAqqQPPuyfie63He",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1VpvtSaSxKvykrqajFJTZqCXgoVJ5cKaM1",
"change": "-320000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz1VpvtSaSxKvykrqajFJTZqCXgoVJ5cKaM1",
"cycle": 219,
"change": "320000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz1VpvtSaSxKvykrqajFJTZqCXgoVJ5cKaM1",
"cycle": 219,
"change": "6250000"
}
],
"delegate": "tz1VpvtSaSxKvykrqajFJTZqCXgoVJ5cKaM1",
"slots": [
30,
28,
18,
14,
8
]
}
}
],
"signature": "sigh5JXbetFfwJKxPjhMAjaPnBjEjyNHq2HVHF4nw1ZAenspa5bwSAHzxvZ7L7JqksbbU9AHxXYbqbaLb3HCLDKU7MGXscZi"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "oozB7vu2X9TYp1qncjiskgCjpDKBHkgr2WPLuRSkxd1ak6tUdtF",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "endorsement",
"level": 450403,
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"change": "-128000000"
},
{
"kind": "freezer",
"category": "deposits",
"delegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"cycle": 219,
"change": "128000000"
},
{
"kind": "freezer",
"category": "rewards",
"delegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"cycle": 219,
"change": "2500000"
}
],
"delegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"slots": [
20,
1
]
}
}
],
"signature": "sigUWRWome9H3pEMpCo6ccPuQqWPExZoMYFy6yNrLKcF1Qn3YV69DRU7NZ17zWT8PYpk64xRjBuTqdV7c8f3tzRcmEH5j9nT"
}
],
[],
[],
[
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "onvrZRcjANGZMGukzSyywitdstNpotaHrWfZFsaZUBfNgodoKtx",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "origination",
"source": "tz1d9h3tviTEqmbjG4ioWjBLpJj7VrRQA4Gs",
"fee": "6720",
"counter": "531146",
"gas_limit": "23404",
"storage_limit": "4615",
"balance": "0",
"script": {
"code": [
{
"prim": "parameter",
"args": [
{
"prim": "or",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
}
]
}
],
"annots": [
"%requests"
]
},
{
"prim": "contract",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
}
],
"annots": [
"%request"
]
},
{
"prim": "nat",
"annots": [
"%balance"
]
}
]
}
]
}
],
"annots": [
"%callback"
]
}
],
"annots": [
"%balance_of"
]
},
{
"prim": "or",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%from_"
]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%to_"
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat",
"annots": [
"%token_id"
]
},
{
"prim": "nat",
"annots": [
"%amount"
]
}
]
}
]
}
],
"annots": [
"%txs"
]
}
]
}
],
"annots": [
"%transfer"
]
},
{
"prim": "list",
"args": [
{
"prim": "or",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%operator"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
}
]
}
],
"annots": [
"%add_operator"
]
},
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%operator"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
}
]
}
],
"annots": [
"%remove_operator"
]
}
]
}
],
"annots": [
"%update_operators"
]
}
]
}
]
}
]
},
{
"prim": "storage",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
],
"annots": [
"%ledger"
]
},
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "address"
}
]
},
{
"prim": "unit"
}
],
"annots": [
"%operators"
]
},
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
]
}
],
"annots": [
"%token_metadata"
]
}
]
}
]
}
]
},
{
"prim": "code",
"args": [
[
{
"prim": "CAST",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "or",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "contract",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
},
{
"prim": "or",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "list",
"args": [
{
"prim": "or",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "address"
}
]
},
{
"prim": "unit"
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "CDR"
},
{
"prim": "DUP"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "CDR"
},
{
"prim": "DUP"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "CDR"
}
]
]
}
]
]
}
]
]
},
{
"prim": "DUP"
},
{
"prim": "DUP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
},
[]
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "list",
"args": [
{
"prim": "nat"
}
]
},
[]
]
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "CONS"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "1"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "CONS"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
}
],
[
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "CONS"
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUP"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[],
[
{
"prim": "UNIT"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_TOKEN_UNDEFINED"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
},
[]
]
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CONS"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "1"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CDR"
},
{
"prim": "AMOUNT"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "TRANSFER_TOKENS"
},
{
"prim": "DUG",
"args": [
{
"int": "10"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "10"
},
[
{
"prim": "CONS"
}
]
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
}
],
[
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "SENDER"
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "CDR"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "NIL",
"args": [
{
"prim": "nat"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "CONS"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[],
[
{
"prim": "UNIT"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_TOKEN_UNDEFINED"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DIP",
"args": [
{
"int": "5"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "COMPARE"
},
{
"prim": "GT"
},
{
"prim": "IF",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PAIR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_INSUFFICIENT_BALANCE"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
],
[]
]
}
],
[
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "SUB"
},
{
"prim": "ISNAT"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PAIR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_INSUFFICIENT_BALANCE"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
{
"int": "5"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "7"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "7"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
},
{
"prim": "DIP",
"args": [
{
"int": "9"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "8"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP"
},
{
"prim": "DIP",
"args": [
{
"int": "5"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
},
{
"prim": "DIP",
"args": [
{
"int": "7"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "6"
}
]
}
],
[
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ADD"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "5"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
},
{
"prim": "DIP",
"args": [
{
"int": "8"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "7"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
}
]
]
}
],
[
{
"prim": "PUSH",
"args": [
{
"prim": "bool"
},
{
"prim": "False"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "6"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "DUP"
},
{
"prim": "SENDER"
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[],
[
{
"prim": "PUSH",
"args": [
{
"prim": "bool"
},
{
"prim": "True"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "IF",
"args": [
[
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "NIL",
"args": [
{
"prim": "nat"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "CONS"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[],
[
{
"prim": "UNIT"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_TOKEN_UNDEFINED"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DIP",
"args": [
{
"int": "7"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "7"
}
]
},
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "6"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "COMPARE"
},
{
"prim": "GT"
},
{
"prim": "IF",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PAIR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_INSUFFICIENT_BALANCE"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
],
[]
]
}
],
[
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "SUB"
},
{
"prim": "ISNAT"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PAIR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_INSUFFICIENT_BALANCE"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
{
"int": "5"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "9"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "9"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
},
{
"prim": "DIP",
"args": [
{
"int": "11"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "10"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP"
},
{
"prim": "DIP",
"args": [
{
"int": "7"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "7"
}
]
},
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
},
{
"prim": "DIP",
"args": [
{
"int": "9"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "8"
}
]
}
],
[
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ADD"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "5"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
},
{
"prim": "DIP",
"args": [
{
"int": "10"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "9"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
}
]
]
}
],
[
{
"prim": "UNIT"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_NOT_OPERATOR"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUP"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
},
[]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "CAR"
},
{
"prim": "CONTRACT",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "address"
}
]
}
],
"annots": [
"%tokens_received"
]
},
{
"prim": "DUP"
},
{
"prim": "IF_NONE",
"args": [
[],
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "mutez"
},
{
"int": "0"
}
]
},
{
"prim": "NIL",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "7"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "7"
}
]
},
{
"prim": "CAR"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "NIL",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "6"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "CAR"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DIP",
"args": [
{
"int": "6"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DIP",
"args": [
{
"int": "6"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
}
]
]
},
{
"prim": "PAIR"
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "CONS"
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "CONS"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "SENDER"
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "TRANSFER_TOKENS"
},
{
"prim": "DUG",
"args": [
{
"int": "11"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "11"
},
[
{
"prim": "CONS"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "CDR"
}
]
]
},
{
"prim": "PAIR"
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CONS"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
}
]
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "CONTRACT",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "address"
}
]
}
],
"annots": [
"%tokens_sent"
]
},
{
"prim": "DUP"
},
{
"prim": "IF_NONE",
"args": [
[],
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "mutez"
},
{
"int": "0"
}
]
},
{
"prim": "NIL",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "6"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "CAR"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DIP",
"args": [
{
"int": "5"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "CONS"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "SENDER"
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "TRANSFER_TOKENS"
},
{
"prim": "DUG",
"args": [
{
"int": "10"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "10"
},
[
{
"prim": "CONS"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP"
}
],
[
{
"prim": "DUP"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "NIL",
"args": [
{
"prim": "nat"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "CONS"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[],
[
{
"prim": "UNIT"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_TOKEN_UNDEFINED"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUP"
},
{
"prim": "SENDER"
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[],
[
{
"prim": "UNIT"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "NOT_OWNER"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "DIP",
"args": [
{
"int": "6"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "UNIT"
},
{
"prim": "SOME"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
},
{
"prim": "DIP",
"args": [
{
"int": "8"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "7"
}
]
}
],
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
}
],
[
{
"prim": "NIL",
"args": [
{
"prim": "nat"
}
]
},
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "CONS"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[],
[
{
"prim": "UNIT"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_TOKEN_UNDEFINED"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUP"
},
{
"prim": "SENDER"
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[],
[
{
"prim": "UNIT"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "NOT_OWNER"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "DIP",
"args": [
{
"int": "6"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "DUP"
},
{
"prim": "DIP",
"args": [
{
"int": "2"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "3"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[],
[
{
"prim": "DIP",
"args": [
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "NONE",
"args": [
{
"prim": "unit"
}
]
},
{
"prim": "DIP",
"args": [
{
"int": "4"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIP",
"args": [
{
"int": "5"
},
[
{
"prim": "DUP"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
},
{
"prim": "DIP",
"args": [
{
"int": "9"
},
[
{
"prim": "DROP"
}
]
]
},
{
"prim": "DUG",
"args": [
{
"int": "8"
}
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
}
]
]
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "DROP"
}
]
]
}
]
]
},
{
"prim": "DROP"
},
{
"prim": "DROP"
},
{
"prim": "DIP",
"args": [
[
{
"prim": "PAIR"
}
]
]
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
}
]
]
}
],
"storage": {
"prim": "Pair",
"args": [
[
{
"prim": "Elt",
"args": [
{
"prim": "Pair",
"args": [
{
"bytes": "00009ee7c4b8ac61bba8cb29f36609a34a206cd2cf3d"
},
{
"int": "0"
}
]
},
{
"int": "10"
}
]
}
],
{
"prim": "Pair",
"args": [
[],
[
{
"prim": "Elt",
"args": [
{
"int": "0"
},
[
{
"prim": "Elt",
"args": [
{
"string": "decimals"
},
{
"bytes": "38"
}
]
},
{
"prim": "Elt",
"args": [
{
"string": "name"
},
{
"bytes": "54657374546f6b656e4e616d65"
}
]
},
{
"prim": "Elt",
"args": [
{
"string": "symbol"
},
{
"bytes": "54657374546f6b656e53796d626f6c"
}
]
}
]
]
}
]
]
}
]
}
},
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1d9h3tviTEqmbjG4ioWjBLpJj7VrRQA4Gs",
"change": "-6720"
},
{
"kind": "freezer",
"category": "fees",
"delegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"cycle": 219,
"change": "6720"
}
],
"operation_result": {
"status": "applied",
"big_map_diff": [
{
"action": "alloc",
"big_map": "68293",
"key_type": {
"prim": "nat"
},
"value_type": {
"prim": "map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
]
}
},
{
"action": "update",
"big_map": "68293",
"key_hash": "exprtZBwZUeYYYfUs9B9Rg2ywHezVHnCCnmF9WsDQVrs582dSK63dC",
"key": {
"int": "0"
},
"value": [
{
"prim": "Elt",
"args": [
{
"string": "decimals"
},
{
"bytes": "38"
}
]
},
{
"prim": "Elt",
"args": [
{
"string": "name"
},
{
"bytes": "54657374546f6b656e4e616d65"
}
]
},
{
"prim": "Elt",
"args": [
{
"string": "symbol"
},
{
"bytes": "54657374546f6b656e53796d626f6c"
}
]
}
]
},
{
"action": "alloc",
"big_map": "68292",
"key_type": {
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "address"
}
]
},
"value_type": {
"prim": "unit"
}
},
{
"action": "alloc",
"big_map": "68291",
"key_type": {
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
"value_type": {
"prim": "nat"
}
},
{
"action": "update",
"big_map": "68291",
"key_hash": "expruuwxtqHHePTb494Ep2H4kBNddHnivMnBH7F7ZFKHLtJkAkAYX3",
"key": {
"prim": "Pair",
"args": [
{
"bytes": "00009ee7c4b8ac61bba8cb29f36609a34a206cd2cf3d"
},
{
"int": "0"
}
]
},
"value": {
"int": "10"
}
}
],
"balance_updates": [
{
"kind": "contract",
"contract": "tz1d9h3tviTEqmbjG4ioWjBLpJj7VrRQA4Gs",
"change": "-1084500"
},
{
"kind": "contract",
"contract": "tz1d9h3tviTEqmbjG4ioWjBLpJj7VrRQA4Gs",
"change": "-64250"
}
],
"originated_contracts": [
"KT1VCzWsjuFP51KF3Ew1cw1TyCCnk9Cr1swy"
],
"consumed_gas": "23304",
"consumed_milligas": "23303207",
"storage_size": "4338",
"paid_storage_size_diff": "4338"
}
}
}
],
"signature": "sighzDSSStbsVLwLw58RdFHWCFuZHCFi4uKaSfNdFfFmWbxjzwg2zat3tWrdw9G9Xo6JTqBqdaRrJ7mvEZk5gNN9w4aEESHY"
},
{
"protocol": "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",
"chain_id": "NetXm8tYqnMWky1",
"hash": "ooNDfSKFc4a1GktgAT2fJgs3aM54wPJzgdTtLjJLxZSY43orCNX",
"branch": "BLoaLi5jowAJ6yfj49h8akJYFSjLooLbYFM99qNxadqD25CxibQ",
"contents": [
{
"kind": "transaction",
"source": "tz1QwPbZtpjJ3Jv7VJjFgs2dEcjqCFDhmzi2",
"fee": "3876",
"counter": "901362",
"gas_limit": "36000",
"storage_limit": "67",
"amount": "0",
"destination": "KT1PS2jZVzNMW54UsnqBqwwkArXnAZ29jiTF",
"parameters": {
"entrypoint": "reward",
"value": {
"prim": "Unit"
}
},
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1QwPbZtpjJ3Jv7VJjFgs2dEcjqCFDhmzi2",
"change": "-3876"
},
{
"kind": "freezer",
"category": "fees",
"delegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
"cycle": 219,
"change": "3876"
}
],
"operation_result": {
"status": "applied",
"storage": {
"prim": "Pair",
"args": [
{
"prim": "Pair",
"args": [
{
"prim": "Pair",
"args": [
{
"prim": "Pair",
"args": [
{
"bytes": "000060acfce59e5fc6ab30149af862ddd18414e2d1b3"
},
{
"prim": "False"
}
]
},
{
"prim": "None"
}
]
},
{
"prim": "Pair",
"args": [
{
"prim": "Pair",
"args": [
{
"int": "50268"
},
{
"int": "50269"
}
]
},
{
"prim": "Pair",
"args": [
{
"int": "50270"
},
{
"int": "50271"
}
]
}
]
}
]
},
{
"prim": "Pair",
"args": [
{
"int": "50272"
},
{
"int": "50273"
}
]
}
]
},
"big_map_diff": [
{
"action": "update",
"big_map": "50268",
"key_hash": "exprtcimBf7WvBkiSYZAzb9ERm8euEWHmGTTwjdKPKkhRg5JKdT8fe",
"key": {
"prim": "Pair",
"args": [
{
"bytes": "00003a212679762a2f328e92077054d6712602e41c78"
},
{
"int": "7"
}
]
},
"value": {
"int": "3"
}
},
{
"action": "update",
"big_map": "50268",
"key_hash": "exprvRpcJKt5pyiw44SFWgDgiLn9DAt1Hoa7L1YvSPYTy2dXd7xBy5",
"key": {
"prim": "Pair",
"args": [
{
"bytes": "000060acfce59e5fc6ab30149af862ddd18414e2d1b3"
},
{
"int": "7"
}
]
},
"value": {
"int": "4994"
}
}
],
"consumed_gas": "34276",
"consumed_milligas": "34275970",
"storage_size": "16022"
}
}
}
],
"signature": "sigksQC3Aprw9zUcV3EwFeTpFr3CetA4TordgKKHhEuivHzZmKWHCj9niwwZdHGVtkfhXqh3mPLBvXf6uT7pvrYkJFXuTq25"
}
]
]
}
Reward Status
| status_id | enum | description |
|---|---|---|
| 1 | DETECTED_ON_CHAIN | When the Quest Criteria matches it is written into the db |
| 2 | AWAITING_ADMIN_TRANSFER | Updated once to this status when the block FITNESS_LEVEL has been reached |
| 3 | MEMORY_POOL | The Quest Rewarder scans the db for anything AWAITING_ADMIN_TRANSFER and initiates the FA2 transfer |
| 4 | CONFIRMED | Once the FITNESS_LEVEL of the FA2 transfer is reached |
| 5 | ERROR | If there was an Error in the FA2 transfer |
Quest Daily Rewards
This daily reward gets written into the db and can be accessed from the API endpoint /v1/daily_reward. The daily reward is a special quest that can be done every day. The operation filter for it looks like:
{
filter_type: 'DAILY',
name: 'daily reward',
reward: 'operations:contents:0:source',
criteria: {
'operations:chain_id': 'NetXm8tYqnMWky1',
'operations:contents:kind': 'transaction',
'operations:contents:amount': { 'eval': 'value == 0' },
'operations:contents:parameters:entrypoint': 'reward',
'operations:contents:destination': <contractFA2>,
}
}
contractFA2 is any/all Game Contracts
The token_id for the daily_reward is current extracted from the block by iterating through the metadata big_map_diff and finding the ledger changes:
export function getLedgerMeta(contract: ContractResponse, operation: OperationEntry): IBigMapLedger[] {
// Get the storage raw schema from the contract
const storage: any = (<any>contract).script.code.find((x: any) => x.prim === 'storage').args[0]
const schemaStorage = Schema.fromRPCResponse(contract)
// decode the storage schema to object
const schemaDecoded = schemaStorage.Execute(contract.script.storage)
// Get the ledger key pointer
const annotKey = 'ledger'
const ledgerMichelson = JSONPath({ path: `$..args[?(@.annots == '%${annotKey}')]`, json: storage })[0]
const ledgerPtr = JSONPath({ path: `$..${annotKey}`, json: schemaDecoded })[0]
// get the BigMap diff metadata from this operation
const meta = getMetadataFromOperation(operation)
const bigMapLedgerDiffs = meta.operation_result.big_map_diff.filter((bm: any) => bm?.big_map == ledgerPtr)
// Iterate through the Ledger BigMap Diffs and get the values
const ledgerBigMapDiffs: IBigMapLedger[] = []
for (const bigMapDiff of bigMapLedgerDiffs) {
const value = (<any>bigMapDiff)?.value?.int || null
const pair = bigMapDiff.key['args']
ledgerBigMapDiffs.push({
address: addressFromHex(pair[0].bytes),
token_id: pair[1].int,
value
})
}
// console.log('ledger => \n', JSON.stringify(entriesPairs, null, 2))
return ledgerBigMapDiffs
}
Below is a break down this function:
- Derive the the contract schema. The raw contract looks like quest contract
- decode the storage pointers from the raw contract. It will something like this:
{ "admin": { "admin": "tz1ZufAMPExipHNGDUm88ZXJqn2fUi3V5hLd", "paused": false, "pending_admin": null }, "assets": { "ledger": "38166", "operators": "38167", "token_metadata": "38168", "token_total_supply": "38169" }, "metadata": "38170", "users": "38171" } - find the
ledgerpointer, in this case foredo2netit is38166 - get the schema for ledger (where the
annotsis%ledger)$..args[?(@.annots == '%ledger')]
{ "prim": "big_map", "args": [ { "prim": "pair", "args": [ { "prim": "address" }, { "prim": "nat" } ] }, { "prim": "nat" } ], "annots": [ "%ledger" ] } - inside the metadata from the operation, the big_map_diff is found and filtered only where
big_mapis equal toledgerPtr. See opertion for an example operation metadata{ "action": "update", "big_map": "38166", "key_hash": "expruY8oYiagXWP11Z4Air5BKpqYcwErCxkQQpzKbnFey4Pkig7eN2", "key": { "prim": "Pair", "args": [ { "bytes": "00007c01f0b92731849bd501249bf4a30d48240e21e8" }, { "int": "16" } ] }, "value": { "int": "1" } }, { "action": "update", "big_map": "38166", "key_hash": "expru3SULaK5xPwNKyhevUwzYZabWMbNjAekNxsrzn2qLk4zAZ98ZN", "key": { "prim": "Pair", "args": [ { "bytes": "00009c8671920e9b4ac694058b5a69fedf3dede6ed5a" }, { "int": "16" } ] }, "value": { "int": "49999" } } - The BigMapDiffs are then decoded based on the
ledgerSchemaand encoded into an object like the below:[ { "address": "tz1Wwioir9n34AL3wDiPE2fP7KvjPgL7HNst", "token_id": "16", "value": "1" }, { "address": "tz1ZufAMPExipHNGDUm88ZXJqn2fUi3V5hLd", "token_id": "16", "value": "49999" } ] - to get the
token_idfor the API endpoint, the firsttoken_idfound with therewardaddress is used
Quest Contract
Below is the json returned from the RPC endpoint: chains/main/blocks/head/contracts/KT1RUSCZ7pJ3WNTuXFD44UpStmNRjA459guZ on edo2net
{
"balance": "0",
"script": {
"code": [
{
"prim": "parameter",
"args": [
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{
"prim": "unit",
"annots": [
"%confirm_admin"
]
},
{
"prim": "bool",
"annots": [
"%pause"
]
}
]
},
{
"prim": "address",
"annots": [
"%set_admin"
]
}
],
"annots": [
"%admin"
]
},
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
}
]
}
],
"annots": [
"%requests"
]
},
{
"prim": "contract",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
}
],
"annots": [
"%request"
]
},
{
"prim": "nat",
"annots": [
"%balance"
]
}
]
}
]
}
],
"annots": [
"%callback"
]
}
],
"annots": [
"%balance_of"
]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%from_"
]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%to_"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
},
{
"prim": "nat",
"annots": [
"%amount"
]
}
]
}
],
"annots": [
"%txs"
]
}
]
}
],
"annots": [
"%transfer"
]
}
]
},
{
"prim": "list",
"args": [
{
"prim": "or",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "address",
"annots": [
"%operator"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
}
],
"annots": [
"%add_operator"
]
},
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "address",
"annots": [
"%operator"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
}
],
"annots": [
"%remove_operator"
]
}
]
}
],
"annots": [
"%update_operators"
]
}
],
"annots": [
"%assets"
]
}
]
},
{
"prim": "or",
"args": [
{
"prim": "nat",
"annots": [
"%claim"
]
},
{
"prim": "unit",
"annots": [
"%reward"
]
}
]
}
]
},
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
},
{
"prim": "nat",
"annots": [
"%amount"
]
}
]
}
],
"annots": [
"%burn_tokens"
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat",
"annots": [
"%token_id"
]
},
{
"prim": "map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
],
"annots": [
"%token_info"
]
}
],
"annots": [
"%create_token"
]
}
]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%owner"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
},
{
"prim": "nat",
"annots": [
"%amount"
]
}
]
}
],
"annots": [
"%mint_tokens"
]
}
],
"annots": [
"%tokens"
]
}
]
}
]
},
{
"prim": "storage",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%admin"
]
},
{
"prim": "bool",
"annots": [
"%paused"
]
}
]
},
{
"prim": "option",
"args": [
{
"prim": "address"
}
],
"annots": [
"%pending_admin"
]
}
],
"annots": [
"%admin"
]
},
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
],
"annots": [
"%ledger"
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "unit"
}
],
"annots": [
"%operators"
]
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "pair",
"args": [
{
"prim": "nat",
"annots": [
"%token_id"
]
},
{
"prim": "map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
],
"annots": [
"%token_info"
]
}
]
}
],
"annots": [
"%token_metadata"
]
},
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
],
"annots": [
"%token_total_supply"
]
}
],
"annots": [
"%assets"
]
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
],
"annots": [
"%metadata"
]
},
{
"prim": "big_map",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "timestamp",
"annots": [
"%drt"
]
},
{
"prim": "nat",
"annots": [
"%placeholder"
]
}
]
}
],
"annots": [
"%users"
]
}
]
}
]
},
{
"prim": "code",
"args": [
[
{
"prim": "NOW"
},
{
"prim": "PUSH",
"args": [
{
"prim": "int"
},
{
"int": "24"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "PACK"
},
{
"prim": "BLAKE2B"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "bool"
},
{
"prim": "True"
}
]
},
{
"prim": "LOOP",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "ADD"
},
{
"prim": "DUG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "SLICE"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "bool"
},
{
"prim": "False"
}
]
}
],
[
{
"prim": "SWAP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "2"
}
]
},
{
"prim": "MUL"
},
{
"prim": "SWAP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "bytes"
},
{
"bytes": "80"
}
]
},
{
"prim": "COMPARE"
},
{
"prim": "LE"
},
{
"prim": "IF",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "ADD"
}
],
[]
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "bool"
},
{
"prim": "True"
}
]
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DUG",
"args": [
{
"int": "3"
}
]
}
]
]
},
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "EDIV"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "MOD by 0"
}
]
},
{
"prim": "FAILWITH"
}
],
[]
]
},
{
"prim": "CDR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_TOKEN_UNDEFINED"
}
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_INSUFFICIENT_BALANCE"
}
]
},
{
"prim": "LAMBDA",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "nat"
},
[
{
"prim": "UNPAIR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
}
],
[]
]
}
]
]
},
{
"prim": "DUP"
},
{
"prim": "LAMBDA",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "lambda",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "nat"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
},
[
{
"prim": "UNPAIR"
},
{
"prim": "SWAP"
},
{
"prim": "UNPAIR"
},
{
"prim": "UNPAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "UNPAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ADD"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[
{
"prim": "DROP"
},
{
"prim": "NONE",
"args": [
{
"prim": "nat"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "UPDATE"
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "SOME"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "UPDATE"
}
]
]
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "APPLY"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "LAMBDA",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "lambda",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "nat"
}
]
},
{
"prim": "string"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
},
[
{
"prim": "UNPAIR"
},
{
"prim": "UNPAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "UNPAIR"
},
{
"prim": "UNPAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "UNPAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "SUB"
},
{
"prim": "ISNAT"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[
{
"prim": "DROP"
},
{
"prim": "NONE",
"args": [
{
"prim": "nat"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "UPDATE"
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "SOME"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "UPDATE"
}
]
]
}
]
]
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "APPLY"
},
{
"prim": "DUP",
"args": [
{
"int": "5"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR",
"args": [
{
"int": "3"
}
]
},
{
"prim": "LAMBDA",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "lambda",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "string"
},
{
"prim": "string"
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "unit"
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
]
}
]
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "unit"
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
]
}
]
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
},
[
{
"prim": "UNPAIR"
},
{
"prim": "UNPAIR",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "UNPAIR"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ITER",
"args": [
[
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "SUB"
},
{
"prim": "ISNAT"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DUP",
"args": [
{
"int": "5"
}
]
},
{
"prim": "FAILWITH"
}
],
[]
]
},
{
"prim": "SOME"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "UPDATE"
}
]
]
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "APPLY"
},
{
"prim": "LAMBDA",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "bool"
}
]
},
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
}
]
},
{
"prim": "unit"
},
[
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "SENDER"
},
{
"prim": "COMPARE"
},
{
"prim": "NEQ"
},
{
"prim": "IF",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "NOT_AN_ADMIN"
}
]
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "UNIT"
}
]
]
}
]
]
},
{
"prim": "LAMBDA",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "bool"
}
]
},
{
"prim": "option",
"args": [
{
"prim": "address"
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
},
{
"prim": "nat"
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "unit"
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
]
}
]
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "big_map",
"args": [
{
"prim": "string"
},
{
"prim": "bytes"
}
]
},
{
"prim": "big_map",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "timestamp"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "option",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "timestamp"
},
{
"prim": "nat"
}
]
}
]
},
[
{
"prim": "UNPAIR"
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "GET"
}
]
]
},
{
"prim": "NIL",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "24"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "LEFT",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
},
{
"prim": "LOOP_LEFT",
"args": [
[
{
"prim": "UNPAIR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SUB"
},
{
"prim": "ABS"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "SENDER"
},
{
"prim": "PAIR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "SUB"
},
{
"prim": "ABS"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "RIGHT",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "CONS"
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
},
{
"prim": "LEFT",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
}
]
}
]
]
}
]
]
},
{
"prim": "LAMBDA",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "nat"
}
]
}
]
}
]
}
]
},
[]
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "9"
}
]
},
{
"prim": "UNPAIR"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "7"
}
]
},
{
"prim": "DROP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "SWAP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DUP"
},
{
"prim": "CDR"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DROP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "NO_PENDING_ADMIN"
}
]
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "SENDER"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[
{
"prim": "NONE",
"args": [
{
"prim": "address"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "SENDER"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
}
],
[
{
"prim": "DROP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "NOT_A_PENDING_ADMIN"
}
]
},
{
"prim": "FAILWITH"
}
]
]
}
]
]
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
],
[
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
]
]
}
],
[
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "DROP"
},
{
"prim": "SOME"
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
]
]
},
{
"prim": "UNPAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "IF",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "PAUSED"
}
]
},
{
"prim": "FAILWITH"
}
],
[]
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUP"
},
{
"prim": "CAR"
},
{
"prim": "MAP",
"args": [
[
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "MEM"
},
{
"prim": "NOT"
},
{
"prim": "IF",
"args": [
[
{
"prim": "DROP"
},
{
"prim": "DUP",
"args": [
{
"int": "7"
}
]
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "8"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
}
]
]
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "CDR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "mutez"
},
{
"int": "0"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "TRANSFER_TOKENS"
},
{
"prim": "SWAP"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CONS"
},
{
"prim": "PAIR"
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "LAMBDA",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "address"
}
]
},
{
"prim": "pair",
"args": [
{
"prim": "nat"
},
{
"prim": "big_map",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "pair",
"args": [
{
"prim": "address"
},
{
"prim": "nat"
}
]
}
]
},
{
"prim": "unit"
}
]
}
]
}
]
},
{
"prim": "unit"
},
[
{
"prim": "UNPAIR"
},
{
"prim": "UNPAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "UNPAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[
{
"prim": "DROP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "UNIT"
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "MEM"
},
{
"prim": "IF",
"args": [
[
{
"prim": "UNIT"
}
],
[
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_NOT_OPERATOR"
}
]
},
{
"prim": "FAILWITH"
}
]
]
}
]
]
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "SWAP"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "ITER",
"args": [
[
{
"prim": "SWAP"
},
{
"prim": "DUP",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "MEM"
},
{
"prim": "NOT"
},
{
"prim": "IF",
"args": [
[
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "8"
}
]
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "DUP",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "SENDER"
},
{
"prim": "DUP",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "5"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "8"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "8"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
}
]
]
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
]
]
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "SENDER"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ITER",
"args": [
[
{
"prim": "SWAP"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "IF_LEFT",
"args": [
[],
[]
]
},
{
"prim": "CAR"
},
{
"prim": "COMPARE"
},
{
"prim": "EQ"
},
{
"prim": "IF",
"args": [
[],
[
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_NOT_OWNER"
}
]
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "SWAP"
},
{
"prim": "UNIT"
},
{
"prim": "SOME"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "UPDATE"
}
],
[
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "NONE",
"args": [
{
"prim": "unit"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "UPDATE"
}
]
]
}
]
]
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
]
]
},
{
"prim": "UNPAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
}
]
]
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "7"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "7"
}
]
},
{
"prim": "DROP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DUP"
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "25"
}
]
},
{
"prim": "SENDER"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
],
[
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "bool"
},
{
"prim": "True"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SENDER"
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "bool"
},
{
"prim": "True"
}
]
}
],
[
{
"prim": "PUSH",
"args": [
{
"prim": "int"
},
{
"int": "180"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "NOW"
},
{
"prim": "SUB"
},
{
"prim": "COMPARE"
},
{
"prim": "GT"
}
]
]
},
{
"prim": "COMPARE"
},
{
"prim": "NEQ"
},
{
"prim": "IF",
"args": [
[
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DROP"
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "REWARD_ON_COOLDOWN"
}
]
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "ADD"
},
{
"prim": "SENDER"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "1"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DUP",
"args": [
{
"int": "5"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "NOW"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
},
{
"prim": "SOME"
}
],
[
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
},
{
"prim": "SOME"
}
]
]
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "UPDATE"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
]
]
}
]
]
}
]
]
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "5"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "6"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "SWAP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "IF_LEFT",
"args": [
[
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DUP"
},
{
"prim": "CAR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "SOME"
},
{
"prim": "SWAP"
},
{
"prim": "UPDATE"
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PUSH",
"args": [
{
"prim": "nat"
},
{
"int": "0"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "SOME"
},
{
"prim": "SWAP"
},
{
"prim": "UPDATE"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
}
],
[
{
"prim": "DROP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "PUSH",
"args": [
{
"prim": "string"
},
{
"string": "FA2_DUP_TOKEN_ID"
}
]
},
{
"prim": "FAILWITH"
}
]
]
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
]
]
}
],
[
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "DROP"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ITER",
"args": [
[
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "5"
}
]
},
{
"prim": "SWAP"
},
{
"prim": "EXEC"
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "ITER",
"args": [
[
{
"prim": "SWAP"
},
{
"prim": "DUP"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "GET"
},
{
"prim": "IF_NONE",
"args": [
[
{
"prim": "DROP",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DUP",
"args": [
{
"int": "4"
}
]
},
{
"prim": "FAILWITH"
}
],
[
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CDR"
},
{
"prim": "ADD"
},
{
"prim": "SOME"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "UPDATE"
}
]
]
}
]
]
},
{
"prim": "DIG",
"args": [
{
"int": "4"
}
]
},
{
"prim": "DROP"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "DUP"
},
{
"prim": "DUG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "CDR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "NIL",
"args": [
{
"prim": "operation"
}
]
},
{
"prim": "PAIR"
}
]
]
},
{
"prim": "UNPAIR"
},
{
"prim": "DUP",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CDR"
},
{
"prim": "DIG",
"args": [
{
"int": "2"
}
]
},
{
"prim": "DIG",
"args": [
{
"int": "3"
}
]
},
{
"prim": "CAR"
},
{
"prim": "CAR"
},
{
"prim": "PAIR"
},
{
"prim": "PAIR"
},
{
"prim": "SWAP"
},
{
"prim": "PAIR"
}
]
]
}
]
]
}
],
"storage": {
"prim": "Pair",
"args": [
{
"prim": "Pair",
"args": [
{
"prim": "Pair",
"args": [
{
"prim": "Pair",
"args": [
{
"string": "tz1ZufAMPExipHNGDUm88ZXJqn2fUi3V5hLd"
},
{
"prim": "False"
}
]
},
{
"prim": "None"
}
]
},
{
"prim": "Pair",
"args": [
{
"int": "38166"
},
{
"int": "38167"
}
]
},
{
"int": "38168"
},
{
"int": "38169"
}
]
},
{
"int": "38170"
},
{
"int": "38171"
}
]
}
}
}
Operation Metadata
Below is the json returned from the RPC endpoint: chains/main/blocks/106434 on edo2net.
This is filtered to only show operation op62w7HB6YYgedeuH8p16KGeWicJaKHuQKssDhjdfUGzhvM27tb
{
...
[
{
"protocol": "PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",
"chain_id": "NetXSgo1ZT2DRUG",
"hash": "op62w7HB6YYgedeuH8p16KGeWicJaKHuQKssDhjdfUGzhvM27tb",
"branch": "BLHXgvaT6LRMJRrQXvZipWVeBXRTgYfzNBXHzZruQnjuqj2Y9ru",
"contents": [
{
"kind": "reveal",
"source": "tz1Wwioir9n34AL3wDiPE2fP7KvjPgL7HNst",
"fee": "0",
"counter": "167931",
"gas_limit": "1000",
"storage_limit": "0",
"public_key": "edpkv5JWFj32McSbdVybgUpbYk3VKptDZMQzJcqjL1Mq9GojxML7JJ",
"metadata": {
"balance_updates": [],
"operation_result": {
"status": "applied",
"consumed_gas": "1000",
"consumed_milligas": "1000000"
}
}
},
{
"kind": "transaction",
"source": "tz1Wwioir9n34AL3wDiPE2fP7KvjPgL7HNst",
"fee": "6448",
"counter": "167932",
"gas_limit": "60000",
"storage_limit": "150",
"amount": "0",
"destination": "KT1RUSCZ7pJ3WNTuXFD44UpStmNRjA459guZ",
"parameters": {
"entrypoint": "reward",
"value": {
"prim": "Unit"
}
},
"metadata": {
"balance_updates": [
{
"kind": "contract",
"contract": "tz1Wwioir9n34AL3wDiPE2fP7KvjPgL7HNst",
"change": "-6448"
},
{
"kind": "freezer",
"category": "fees",
"delegate": "tz1cXeGHP8Urj2pQRwpAkCdPGbCdqFUPsQwU",
"cycle": 51,
"change": "6448"
}
],
"operation_result": {
"status": "applied",
"storage": {
"prim": "Pair",
"args": [
[
{
"prim": "Pair",
"args": [
{
"prim": "Pair",
"args": [
{
"bytes": "00009c8671920e9b4ac694058b5a69fedf3dede6ed5a"
},
{
"prim": "False"
}
]
},
{
"prim": "None"
}
]
},
{
"prim": "Pair",
"args": [
{
"int": "38166"
},
{
"int": "38167"
}
]
},
{
"int": "38168"
},
{
"int": "38169"
}
],
{
"prim": "Pair",
"args": [
{
"int": "38170"
},
{
"int": "38171"
}
]
}
]
},
"big_map_diff": [
{
"action": "update",
"big_map": "38171",
"key_hash": "exprtzDnCQrxKrWA8Cwd1XLDy8KrZWx8e3JYq1Wqcu5aFRBDUgzbBP",
"key": {
"bytes": "00007c01f0b92731849bd501249bf4a30d48240e21e8"
},
"value": {
"prim": "Pair",
"args": [
{
"int": "1616393129"
},
{
"int": "0"
}
]
}
},
{
"action": "update",
"big_map": "38166",
"key_hash": "expruY8oYiagXWP11Z4Air5BKpqYcwErCxkQQpzKbnFey4Pkig7eN2",
"key": {
"prim": "Pair",
"args": [
{
"bytes": "00007c01f0b92731849bd501249bf4a30d48240e21e8"
},
{
"int": "16"
}
]
},
"value": {
"int": "1"
}
},
{
"action": "update",
"big_map": "38166",
"key_hash": "expru3SULaK5xPwNKyhevUwzYZabWMbNjAekNxsrzn2qLk4zAZ98ZN",
"key": {
"prim": "Pair",
"args": [
{
"bytes": "00009c8671920e9b4ac694058b5a69fedf3dede6ed5a"
},
{
"int": "16"
}
]
},
"value": {
"int": "49999"
}
}
],
"balance_updates": [
{
"kind": "contract",
"contract": "tz1Wwioir9n34AL3wDiPE2fP7KvjPgL7HNst",
"change": "-35500"
}
],
"consumed_gas": "33399",
"consumed_milligas": "33398290",
"storage_size": "16793",
"paid_storage_size_diff": "142",
"lazy_storage_diff": [
{
"kind": "big_map",
"id": "38171",
"diff": {
"action": "update",
"updates": [
{
"key_hash": "exprtzDnCQrxKrWA8Cwd1XLDy8KrZWx8e3JYq1Wqcu5aFRBDUgzbBP",
"key": {
"bytes": "00007c01f0b92731849bd501249bf4a30d48240e21e8"
},
"value": {
"prim": "Pair",
"args": [
{
"int": "1616393129"
},
{
"int": "0"
}
]
}
}
]
}
},
{
"kind": "big_map",
"id": "38170",
"diff": {
"action": "update",
"updates": []
}
},
{
"kind": "big_map",
"id": "38169",
"diff": {
"action": "update",
"updates": []
}
},
{
"kind": "big_map",
"id": "38168",
"diff": {
"action": "update",
"updates": []
}
},
{
"kind": "big_map",
"id": "38167",
"diff": {
"action": "update",
"updates": []
}
},
{
"kind": "big_map",
"id": "38166",
"diff": {
"action": "update",
"updates": [
{
"key_hash": "expru3SULaK5xPwNKyhevUwzYZabWMbNjAekNxsrzn2qLk4zAZ98ZN",
"key": {
"prim": "Pair",
"args": [
{
"bytes": "00009c8671920e9b4ac694058b5a69fedf3dede6ed5a"
},
{
"int": "16"
}
]
},
"value": {
"int": "49999"
}
},
{
"key_hash": "expruY8oYiagXWP11Z4Air5BKpqYcwErCxkQQpzKbnFey4Pkig7eN2",
"key": {
"prim": "Pair",
"args": [
{
"bytes": "00007c01f0b92731849bd501249bf4a30d48240e21e8"
},
{
"int": "16"
}
]
},
"value": {
"int": "1"
}
}
]
}
}
]
}
}
}
],
"signature": "sigWRnJdY8YyPqWbyJ4av27SimJ3KFXkGgHUhLB9iEHctN4CrnpxSRHogVoRwKztjTCajb7KFQkUgWjTHCvpTab5moPPqvCE"
}
]
...
}
Quest Criteria
Each operation of the block is iterated through for matching filters. If a match is detected it is parsed from reward property of the filter to get the pkh address. A pseudo random number is generated to determine the token_id for FA2 transfer:
- reward property:
operations:contents:0:sourcemeans thesourceproperty the first0contentsof theoperation"contents": [ { ... "source": "tz1d9h3tviTEqmbjG4ioWjBLpJj7VrRQA4Gs", ... } ] - pseudo random number: the sha256 of the concatenated
${operation.hash}${block.header.level}${quest_id}is digested. Then each byte of the sha256 Buffer isaddedtogether thenmodnumber of possible tokens
All matches get written into the db with the Reward Status of DETECTED_ON_CHAIN
Post Processing
After each block indexing a Post Processing procedure is called. This procedure queries the db for anything that with a status of DETECTED_ON_CHAIN that has reached the needed level of block confirmations by FITNESS_LEVEL. It then updates the status to AWAITING_ADMIN_TRANSFER
Orphan Blocks
Occasionally chain forks will occur near the HEAD block. This can result in Orphans Blocks that have been indexed but are no longer part of the chain. In these cases the Indexer will scan the blocks backwards from HEAD until the block at which the fork happened is found and purge the data in the db of any Orphans. The env property DETECT_ORPHAN_BLOCKS will store the historical block header info for this purpose.
BCA Auction
Special logic is created for the BCA Auction House
The operation match looks like:
- MAINNET
{ name: 'auction', description: 'SPECIAL process for auction resolve MAINNET', reward: 'SPECIAL:auction', criteria: { 'operations:chain_id': 'NetXdQprcVkpaWU', 'operations:contents:destination': 'KT1HvpCCHvC9c4iNzAa6rx4MqNsmPRJf6CEw', 'operations:contents:kind': 'transaction', 'operations:contents:parameters:entrypoint': 'resolve' } } - EDO2NET
{ name: 'auction', description: 'SPECIAL process for auction resolve EDO2NET', reward: 'SPECIAL:auction', criteria: { 'operations:chain_id': 'NetXSgo1ZT2DRUG', 'operations:contents:destination': 'KT1WkhPFfhydqqPXWrYFkN9gfpgus1XXCeHy', 'operations:contents:kind': 'transaction', 'operations:contents:parameters:entrypoint': 'resolve', } } - DELPHINET
{ name: 'auction', description: 'SPECIAL process for auction resolve DELPHINET', reward: 'SPECIAL:auction', criteria: { 'operations:chain_id': 'NetXm8tYqnMWky1', 'operations:contents:destination': 'KT1GNhJgAKRorY41TtbqFMKGFkSyCdPiuk2i', 'operations:contents:kind': 'transaction', 'operations:contents:parameters:entrypoint': 'resolve', } }
Indexing
Once a match is detected the contract address operations:contents:destination is used to get the auction BigMap at that BlockLevel using the BETTER_CALL_DEV_ENDPOINT endpoint
export async function getBigMapAtBlockLevel(network: 'delphinet' | 'edo2net' | 'mainnet', contractAddress: string, bigmapName: string, blockLevel: number): Promise<IBCDBigMap> {
const urlPrefix = process.env.BETTER_CALL_DEV_ENDPOINT || 'https://better-call.dev/v1/'
const storage: IBCDStorage = (await axios.get(`${urlPrefix}contract/${network}/${contractAddress}/storage`)).data
const ptr = storage.children.find(c => c.name == bigmapName)
assert(ptr, `cannot find name ${bigmapName} in contract ${contractAddress}, in network ${network}`)
const diffCount = Number((await axios.get(`${urlPrefix}bigmap/${network}/${ptr.value}/count`)).data.count)
const aryBigMapKeys: IBCDBigMapKeys[] = (await axios.get(`${urlPrefix}bigmap/${network}/${ptr.value}/keys`)).data
// assert(diffCount == aryBigMapKeys.length, 'mismatch key length to diff count')
const key = aryBigMapKeys.find(k => k.data.level == blockLevel)
assert(key, `cannot find key ${bigmapName} in contract ${contractAddress}, in network ${network}, at this blockLevel ${blockLevel}`)
const bigMap = (await axios.get(`${urlPrefix}bigmap/${network}/${ptr.value}/keys/${key.data.key_hash}`)).data
return bigMap
}
The purpose of this is to find the highest_bidder child value and write it into the db at the /v1/special endpoiont
Post Processing
There is special Post Processing for the BCA Auction House. The end_time and auction_id child value is found from BETTER_CALL_DEV_ENDPOINT:
const network = process.env.API_PREFIX
const urlPrefix = process.env.BETTER_CALL_DEV_ENDPOINT || 'https://better-call.dev/v1/'
const storage: IBCDAuctionStorage = (await axios.get(`${urlPrefix}contract/${network}/${this.contractAuctionAddress}/storage`)).data
const bigMapKey = storage.children.find(c => c.name == 'auctions').value
const bigMapAction: IBCDBigMapAuction[] = (await axios.get(`${urlPrefix}bigmap/${network}/${bigMapKey}/keys`)).data
If the current_time is greater than the end_time in the contract BigMap it will call the resolve endpoint with the auction_id
Quest Rewarder
The Quest Rewarder issues FA2 tokens for any Quests that have a Reward Status of AWAITING_ADMIN_TRANSFER
- This process scans the
dbfor anything with a Reward Status ofAWAITING_ADMIN_TRANSFERand batches together any pending transfers by thetezos_signerrequired by the game contract. Thetezos_signercan be seen in the /v1/games endpoint. - It will inject the FA2 transfers and update the Reward Status to
MEMORY_POOL. - Once the chain accepts the FA2 transfer and the fitness level has been reached the Reward Status is updated to
CONFIRMEDorERRORif themetadata.operation_result.status !== 'applied'
Quest Error Handling
If any system critical errors happen you can get alerted via Slack on the watchdog-quest channel. This uses the SLACK_WEBHOOK token for authentication.
Alerts for:
- uncaughtException: causing process crash
- transfer FA2: alerts if either there is an on-chain error or a
taquitolibrary error - special processing: errors in Quest Auction
- block orphans: errors if block forked more than the number of block in DETECT_ORPHAN_BLOCKS
Swagger API docs
If running locally you can access your Swagger API with endpoint /swagger
Ex: http://127.0.0.1:7305/swagger
This endpoint will include any API_PREFIX set in your .env
Ex: http://127.0.0.1:7305/mainnet/swagger
All endpoints start with
${host}/${API_PREFIX}/v1/and will increment based on updates as to not disrupt legacy processes
/v1 endpoint paths { GET }
[
'/',
'/status',
'/games',
'/admin_game',
'/daily_reward',
'/quests',
'/rewards_pending/{game_id}',
'/special'
]
Currently public endpoints being supported here:
- mainnet: https://reward.tezos.help/mainnet/swagger
- delphinet: https://reward.tezos.help/delphinet/swagger
- edo2net: https://reward.tezos.help/edo2net/swagger
Developers
This is for Developers wanting to run their own Quest Indexer. The next few sections describe different ways to build, deploy, and configure this system
Project Dependencies
Dependencies
node v14.16.0
Recommend to use NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
# nvm install <SPECIFIC_NODE_VERSION>
nvm install v14.16.0
nvm use v14.16.0
node -v
# v14.16.0
TypeScript
npm install -g typescript
sqlite dependencies
# install build-essentials
sudo apt-get update && sudo apt-get install build-essential
# install node-gyp
npm install -g node-gyp
Building the Quest Indexer
# use node version v14.16.0 in .nvmrc
nvm use
# update npm
npm install -g npm
# install all the packages
npm install
# copy _dev.env and configure .env as desired
# See more information about the config below
cp _dev.env .env
# build the indexer and api server
npm run build
# run test
npm run tests
configure your environment environment .env config
Configure Environment
Create a file .env in root dir or use the --path-env=<file> option when running the process.
use the _dev.env as a guide for creating your own
# Server Config
API_BINDIP="127.0.0.1"
API_PORT="7305"
API_PREFIX="edo2net"
API_SSL=false # true if you want server to be SSL but will need to also include certificate CA_PRIVATE_KEY_PEM and CA_CERTIFICATE_PEM
# REQUIRED if API_SSL is true and you want nodejs to run https instead of http
CA_PRIVATE_KEY_PEM=""
CA_CERTIFICATE_PEM=""
# This is currently only needed to special auction contract big_map diff
BETTER_CALL_DEV_ENDPOINT="https://better-call.dev/v1/"
# This needs to be a string array of secret keys that will be used for automatic Quest Rewards
# If this is not provide you will need to manually issue any rewards
SIGNER_SK='["edskRuDGPt64QMY3hmC1xg7MZTSMpsLnmoHRvkJDaWH7tfnzYhr8NGfK3ZNeaVxSbgzzTtkyGQecjbLgEZ6BSkfEnrN1xbmCS2","edskRjPHRWoqy6qkobFDHPBs6SP6dYeuhb6i64kEqvwFegYaugyoRmLvjgTYg6dsHzBXEyFoezh4dz9jrhrbv6HAYkrqsEs4So"]'
# path to sqlite
DB_PATH="./db/indexer.db"
# This is for interacting with the RPC node
# https://github.com/ecadlabs/taquito/blob/master/docs/rpc_nodes.md
# https://tezostaquito.io/docs/rpc_nodes
RPC_ENDPOINT="https://edonet.smartpy.io"
CHAIN_ID="NetXSgo1ZT2DRUG"
# (Optional) for special processing of the auction contract
AUCTION_CONTRACT="KT1WkhPFfhydqqPXWrYFkN9gfpgus1XXCeHy"
# Polling Frequency of the Quest Criteria Process
POLLING_FREQUENCY=20000 # Every 20 seconds
# Polling Frequency of the Quest Rewarder Process
POLLING_BROADCAST=2000 # Every 2 seconds
# block_level to start the syncronizing the indexer on chain
BLOCK_START=96000
# block_level to stop the indexer. If 0 it will continue indefinitely
BLOCK_END=0
# How many blocks to keep in memory for resyncing in case of forks, orphans, or uncles
DETECT_ORPHAN_BLOCKS=20
# how many block confirmation are needed before a block is considered safe
FITNESS_LEVEL=3
# Maximum time to wait for a FA2 reward to move from mempool into block
# If the FA2 transfer does not confirm within this time, an error will be recorded and will have to be looked into manually
# The Quest Rewarder process will continue with the next batch after timeout is reached
TAQUITO_TIMEOUT=600 # 10 min
# https://api.slack.com/apps
# https://api.slack.com/apps/<app_id>/incoming-webhooks
# To receive notifications of errors Slack
SLACK_WEBHOOK=""
Deploying the Quest Indexer
- Run as Node process
# simple start using env config
npm run start
# or to run as a daemon process
npm run start:daemon --silent
To run as a systemd process
sudo mkdir /opt/quest-indexer && sudo chown $USER /opt/quest-indexer
cd /opt/quest-indexer
git clone https://gitlab.com/Thomas66777/quest-indexer.git ./
cp _dev.env .env
npm install
npm run build
sudo bash -c 'cat >> /etc/systemd/system/quest-indexer.service <<EOL
[Unit]
Description=quest-indexer
After=syslog.target
After=network.target
[Service]
Type=simple
ExecStart=node /opt/quest-indexer/dist/index.js
Restart=always
WorkingDirectory=/opt/quest-indexer
[Install]
WantedBy=multi-user.target
EOL'
sudo systemctl daemon-reload
# To start systemd service now
sudo systemctl start quest-indexer.service
# To start at system boot
sudo systemctl enable quest-indexer.service
Simply run with default config
# simple start using env config
npm run start
Run with logging
# run with seperate logging for console and errors
node ./dist/index.js >>log-console 2>>log-error
Run with custom options
# support for cli options
# see all supported cli options
node ./dist/index.js --help
node ./dist/index.js --path-env=my_custom_env
Run Headless as daemon process
# or to run as a daemon process
npm run start:daemon --silent
Deploy as a systemd process
sudo mkdir /opt/quest-indexer && sudo chown $USER /opt/quest-indexer
cd /opt/quest-indexer
git clone https://gitlab.com/Thomas66777/quest-indexer.git ./
cp _dev.env .env
npm install
npm run build
sudo bash -c 'cat >> /etc/systemd/system/quest-indexer.service <<EOL
[Unit]
Description=quest-indexer
After=syslog.target
After=network.target
[Service]
Type=simple
ExecStart=node /opt/quest-indexer/dist/index.js
Restart=always
WorkingDirectory=/opt/quest-indexer
[Install]
WantedBy=multi-user.target
EOL'
sudo systemctl daemon-reload
# To start systemd service now
sudo systemctl start quest-indexer.service
# To start at system boot
sudo systemctl enable quest-indexer.service
Database
The database schema can be seen here: db_schema.sql
If you make changes to the DB schema the next time you run the indexer do it with the --dbschema for it to re-exec the schema.sql