Deploy CryptoKitty Contracts
You must be the contract owner in order to create a CryptoKitty
To create your own CryptoKitties to send across the bridge, you need to deploy your own set of contracts. Only the contract owner can create new cats. You can also create a group of cats during the deployment process using an env variable.
In this example, we will deploy contracts to the Kovan & Sokol testnets. You will need a small amount of test currency in your wallet for both testnets in order to deploy the contracts.
If you would like to try to the bridge feature without creating your own cat, please contact us on Discord or the TokenBridge forum with your wallet address, and we will send you a test cat to play with
😻
. With a test cat, you can proceed from NiftyWallet Transfer or MEW transfer.
We use Nifty Wallet for the demonstration. Similar functionality can be achieved with MetaMask. Note that Nifty Wallet & MetaMask cannot be active extensions at the same time.

1) Clone Repository

Prerequisites
  • ​yarn v 1.19.1 (brew install yarn)
  • ​Node versions either: ^8.10.0 || ^10.13.0 ||| >=11.10.1
1
$ git clone --recursive https://github.com/poanetwork/cryptokitties-xdai-demo.git
Copied!

2) Install Dependencies

1
$ cd cryptokitties-xdai-demo
2
$ yarn
Copied!

3) Compile Contracts

1
$ yarn compile
Copied!

4) Create a .env file in the root directory

1
$ nano .env
Copied!

5) Paste/Change example parameters

Copy the following into the .env file, change parameters as needed and save.
Parameters to change based on your address information are noted with a <>. Notes and explanations are below the example file.
1
#The private key hex value of the account responsible for contracts deployment
2
DEPLOYMENT_ACCOUNT_PRIVATE_KEY=<YOUR PRIVATE WALLET KEY>
3
# Extra gas added to the estimated gas of a particular deployment/configuration transaction
4
DEPLOYMENT_GAS_LIMIT_EXTRA=0.2
5
# The RPC channel to a Home node able to handle deployment/configuration transactions.
6
HOME_RPC_URL=https://sokol.poa.network
7
# The "gasPrice" parameter set in every deployment/configuration transaction on Home network (in Wei).
8
HOME_DEPLOYMENT_GAS_PRICE=1000000000
9
# The address of the existing AMB bridge in the Home network that will be used to pass messages
10
# to the Foreign network.
11
HOME_AMB_BRIDGE=0xFe446bEF1DbF7AFE24E81e05BC8B271C1BA9a560
12
# The gas limit that will be used in the execution of the message passed to the mediator contract
13
# in the Foreign network.
14
HOME_MEDIATOR_REQUEST_GAS_LIMIT=1000000
15
# Address on Home network with permissions to change parameters of the mediator contract.
16
HOME_MEDIATOR_OWNER=<YOUR WALLET OWNER ADDRESS>
17
# Address on Home network with permissions to upgrade the mediator contract
18
HOME_UPGRADEABLE_ADMIN=<YOUR WALLET OWNER ADDRESS>
19
​
20
# The RPC channel to a Foreign node able to handle deployment/configuration transactions.
21
FOREIGN_RPC_URL=https://kovan.infura.io
22
# The "gasPrice" parameter set in every deployment/configuration transaction on Foreign network (in Wei).
23
FOREIGN_DEPLOYMENT_GAS_PRICE=1000000000
24
# The address of the existing AMB bridge in the Foreign network that will be used to pass messages
25
# to the Home network.
26
FOREIGN_AMB_BRIDGE=0xFe446bEF1DbF7AFE24E81e05BC8B271C1BA9a560
27
# The gas limit that will be used in the execution of the message passed to the mediator contract
28
# in the Home network.
29
FOREIGN_MEDIATOR_REQUEST_GAS_LIMIT=1000000
30
# Address on Foreign network with permissions to change parameters of the mediator contract.
31
FOREIGN_MEDIATOR_OWNER=<YOUR WALLET OWNER ADDRESS>
32
# Address on Foreign network with permissions to upgrade the mediator contract
33
FOREIGN_UPGRADEABLE_ADMIN=<YOUR WALLET OWNER ADDRESS>
34
​
35
# Cryptokitties contract address on Foreign network. If not defined or set to address zero, the contract will be deployed on Foreign network.
36
CRYPTOKITTIES_ADDRESS=0x0000000000000000000000000000000000000000
37
# Amount of Kitties to Mint on Foreign network
38
KITTIES_AMOUNT=15
39
​
Copied!

Parameter Notes:

  • DEPLOYMENT_ACCOUNT_PRIVATE_KEY=<Your Private Wallet Key>: This is the key associated with the account deploying the contracts. This wallet must have both test Ether and test POA. To retrieve a private key from Nifty Wallet:
  • Go to the deployment account and click the dots next to the account name. Select Export Private Key.
Select Export Private Key
  • Enter in your Nifty Wallet password:
Enter Nifty Wallet password
  • Copy your private key.
Click to copy your private key
  • HOME_AMB_BRIDGE=0xFe446bEF1DbF7AFE24E81e05BC8B271C1BA9a560: This is the address for the currently deployed AMB bridge on the Sokol network. If you deploy elsewhere, use your deployed address address.
  • HOME_MEDIATOR_OWNER=<YOUR WALLET OWNER ADDRESS>: You should have access to this wallet address so you can create a cat later if needed. The following <YOUR WALLET OWNER ADDRESS> parameters can use the same address for the purposes of this tutorial. For more information, see TokenBridge roles.
  • FOREIGN_AMB_BRIDGE=0xFe446bEF1DbF7AFE24E81e05BC8B271C1BA9a560: This is the address for the currently deployed AMB bridge on the Kovan network. If you deploy elsewhere, use your deployed address.
  • KITTIES_AMOUNT=15: This is the number of kitties minted by the contract, select any number here. You can send these to other addresses or bridge yourself.

6) Deploy Contracts

1
$ yarn deploy
Copied!
On successful deployment, you will receive confirmation of the contract addresses: For example:
1
[ Home ] homeMediator: 0x5EeC77239398FE328791E28700CAFddB2990ea97
2
[ Home ] simpleKittyCore: 0xc6a592ED792de33e6CBBF7ce04Dd9D3884B46B9A
3
[ Foreign ] foreignMediator: 0x7dB6493D9B6D99D9A240a6914AdAd5e0E8E8BE40
4
[ Foreign ] kittyCore: 0x13AC5C6338796a31A39e74D70B0153C1bE5f53B4
Copied!
In our example, Sokol is the Home network, and Kovan is the Foreign Network. This means CryptoKitties are deployed on Kovan, and can be transferred to Sokol following the next instructions. Once they are bridged to Sokol, they can be bridged back to Kovan as well.
​
​
​