Test bridge
Initialize token contracts
  • Create NFTs on Kylin
For Kylin we'll setup the collection and schema then mint an asset to the test contract. If you have a pre existing NFT, you can send it to the Kylin test account.
Kylin
1
export AUTHOR=$KYLIN_TEST_ACCOUNT
2
export COLLECTION_NAME=nftauthcoll2 # create a different one because this one's taken
3
export ALLOW_NOTIFY=1
4
export AUTHORIZED_ACCOUNTS=[$KYLIN_TEST_ACCOUNT] # add additional accounts if necessary
5
export NOTIFY_ACCOUNTS=[""]
6
export MARKET_FEE=0.01 # cause we're fair people
7
export DATA=[]
8
export SCHEMA_NAME=nftauthschem
9
export SCHEMA_FORMAT=[ {name: "name", type: "string"}, {name: "series", type: "string"}, {name: "moment", type: "string"}, {name: "description", type: "string"}, {name: "img", type: "image"}, {name: "backimg", type: "string"}, {name: "rarity", type: "string"} ]
10
# not working, if you know how to make it (passing array as variable) work, please edit!!
11
# cleos -u $KYLIN_ENDPOINT push action $KYLIN_TOKEN_ACCOUNT createcol "[\"$AUTHOR\",\"$COLLECTION_NAME\",\"$ALLOW_NOTIFY\",\"$AUTHORIZED_ACCOUNTS\",\"$NOTIFY_ACCOUNTS\",\"$MARKET_FEE\",\"$DATA\"]" -p [email protected]
12
​
13
# create collection
14
cleos -u $KYLIN_ENDPOINT push transaction '{
15
"delay_sec": 0,
16
"max_cpu_usage_ms": 0,
17
"actions": [
18
{
19
"account": "bridgeassets",
20
"name": "createcol",
21
"data": {
22
"author": "natdeveloper",
23
"collection_name": "nftauthcoll2",
24
"allow_notify": true,
25
"authorized_accounts": [
26
"natdeveloper"
27
],
28
"notify_accounts": [],
29
"market_fee": 0.01,
30
"data": []
31
},
32
"authorization": [
33
{
34
"actor": "natdeveloper",
35
"permission": "active"
36
}
37
]
38
}
39
]
40
}'
41
​
42
# create schema
43
cleos -u $KYLIN_ENDPOINT push transaction '{
44
"delay_sec": 0,
45
"max_cpu_usage_ms": 0,
46
"actions": [
47
{
48
"account": "bridgeassets",
49
"name": "createschema",
50
"data": {
51
"authorized_creator": "natdeveloper",
52
"collection_name": "nftauthcoll2",
53
"schema_name": "nftauthschem",
54
"schema_format": [
55
{
56
"name": "name",
57
"type": "string"
58
},
59
{
60
"name": "series",
61
"type": "string"
62
},
63
{
64
"name": "moment",
65
"type": "string"
66
},
67
{
68
"name": "description",
69
"type": "string"
70
},
71
{
72
"name": "img",
73
"type": "image"
74
},
75
{
76
"name": "backimg",
77
"type": "string"
78
},
79
{
80
"name": "rarity",
81
"type": "string"
82
}
83
]
84
},
85
"authorization": [
86
{
87
"actor": "natdeveloper",
88
"permission": "active"
89
}
90
]
91
}
92
]
93
}'
Copied!
If you get errors such as Transaction exceeded the current network usage limit imposed on the transaction, see the Kylin account setup guides to get more tokens and to stake for more resources.
  • Mint test tokens
We will mint some test NFT tokens to our test account.
Be sure to update the account name, the new asset owner, the collection name and the actor signing the transaction.
1
export AUTHORIZED_MINTER=$KYLIN_TEST_ACCOUNT
2
export COLLECTION_NAME=$COLLECTION_NAME
3
export SCHEMA_NAME=$SCHEMA_NAME
4
export TEMPLATE_ID=-1
5
export NEW_ASSET_OWNER=$KYLIN_TEST_ACCOUNT
6
export IMMUTABLE_DATA=[ { "key": "name", "value": [ "string", "The New Silk Road" ] }, { "key": "img", "value": [ "string", "QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s/main/genesis/1.png" ] }, { "key": "backimg", "value": [ "string", "QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s/main/genesis/1_back.jpg" ] }, { "key": "series", "value": [ "string", "Through the Looking Glass" ] }, { "key": "moment", "value": [ "string", "6 - The Silk Road" ] }, { "key": "rarity", "value": [ "string", "genesis" ] }, { "key": "description", "value": [ "string", "Named after an ancient Chinese trade route, the digital silk road is a virtual pathway for the delivery of merchandise." ] } ]
7
export MUTABLE_DATA=[]
8
export TOKENS_TO_BACK=[]
9
​
10
cleos -u $KYLIN_ENDPOINT push transaction '{
11
"delay_sec": 0,
12
"max_cpu_usage_ms": 0,
13
"actions": [
14
{
15
"account": "bridgeassets",
16
"name": "mintasset",
17
"data": {
18
"authorized_minter": "natdeveloper",
19
"collection_name": "nftauthcoll2",
20
"schema_name": "nftauthschem",
21
"template_id": -1,
22
"new_asset_owner": "natdeveloper",
23
"immutable_data": [ { "key": "name", "value": [ "string", "The New Silk Road" ] }, { "key": "img", "value": [ "string", "QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s/main/genesis/1.png" ] }, { "key": "backimg", "value": [ "string", "QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s/main/genesis/1_back.jpg" ] }, { "key": "series", "value": [ "string", "Through the Looking Glass" ] }, { "key": "moment", "value": [ "string", "6 - The Silk Road" ] }, { "key": "rarity", "value": [ "string", "genesis" ] }, { "key": "description", "value": [ "string", "Named after an ancient Chinese trade route, the digital silk road is a virtual pathway for the delivery of merchandise." ] } ],
24
"mutable_data": [],
25
"tokens_to_back": []
26
},
27
"authorization": [
28
{
29
"actor": "natdeveloper",
30
"permission": "active"
31
}
32
]
33
}
34
]
35
}'
Copied!
  • Register mapping
The collection author for an NFT must register that NFT with the bridge before users can transfer.
Be sure to update the address to the atomicnft contract address
1
cleos -u $KYLIN_ENDPOINT push transaction '{
2
"delay_sec": 0,
3
"max_cpu_usage_ms": 0,
4
"actions": [
5
{
6
"account": "maticnftbrdg",
7
"name": "regmapping",
8
"data": {
9
"template_id": -1,
10
"schema_name": "nftauthschem",
11
"collection_name": "nftauthcoll2",
12
"address": "0xc68c97B2c24A79F096D4b6503D9a1C6Eef7ce292",
13
"immutable_data": [ { "key": "name", "value": [ "string", "The New Silk Road" ] }, { "key": "img", "value": [ "string", "QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s/main/genesis/1.png" ] }, { "key": "backimg", "value": [ "string", "QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s/main/genesis/1_back.jpg" ] }, { "key": "series", "value": [ "string", "Through the Looking Glass" ] }, { "key": "moment", "value": [ "string", "6 - The Silk Road" ] }, { "key": "rarity", "value": [ "string", "genesis" ] }, { "key": "description", "value": [ "string", "Named after an ancient Chinese trade route, the digital silk road is a virtual pathway for the delivery of merchandise." ] } ],
14
},
15
"authorization": [
16
{
17
"actor": "natdeveloper",
18
"permission": "active"
19
}
20
]
21
}
22
]
23
}'
Copied!
Let's test by sending an NFT across.
1
export FROM=$KYLIN_TEST_ACCOUNT
2
export TO=$KYLIN_BRIDGE_ACCOUNT
3
export ASSET_ID=1099511627781
4
export MEMO="0x92Fb8d9402Cbd918092CE6D00bE86A8bdD13559c"
5
cleos -u $KYLIN_ENDPOINT push action $KYLIN_TOKEN_ACCOUNT transfer "[\"$FROM\",\"$TO\",[\"$ASSET_ID\"],\"$MEMO\"]" -p $KYLIN_TEST_ACCOUNT@active
Copied!
Now let's see if the tokens make it! Navigate to your user account's address
Now let's send it back!
Go to your NFT contract and scroll to #11. Set operator to atomictokenpeg contract account, and approved to 1.
Click on the contract tab, go to Write Contract, and connect using your user's account.
Then go to the atomictokenpeg contract and scroll to #4. Type in the tokenId from the transaction that was sent to your user account.
To determine the destination address we're going to use a helper function on our bridge contract.
1
cleos -u $EOS_ENDPOINT push action $KYLIN_BRIDGE_ACCOUNT getdest '["YOUR EOSIO USER ACCOUNT HERE"]' -p $KYLIN_BRIDGE_ACCOUNT@active
Copied!
The assertion error will relay the uint64_t for the account specified, and you said EOSIO assertion messages weren't good for anything, pish posh, we move on!
Destination EOSIO Account Name Value: 11075078730411234672
The token contract is the atomicnft token contract.
Fire. Example trx​
Copy link