Deploy spin-contracts

In future version, these contracts will only needed to be deployed once per chain.

zkSpin provides a series of on-chain smart contracts. They act as a central hub.

Prerequisite

  • Node.js >= 20.0

Obtain your chain's information

We need two piece of information:

1. RPC node URL

This can be a public node or from node vendor like Alchemy or Infura. For a local hardhat or ganache node, this could be http://localhost:8545

Local development

You can use hardhat to start a testnet locally for development. Follow the steps below.

2. Private key of an account with enough gas fee to pay for deployment

Example

0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

Deploy the smart contracts

This guide deploys the contracts via hardhat

  1. Obtain the smart contracts

git clone https://github.com/zkspin/opzk.git
  1. Go into spin-contracts

cd opzk/spin-contracts/
Local development

Open a new terminal and run npm run node to start a local hardhat network. Leave the .env with the same values as in .env.template

  1. Fill in .env with your account private key and node RPC following .env.template

  2. Install hardhat and dependencies

npm install
  1. Deploy the contracts

npm run deploy-contracts

The above command will generate outputs of the contract address deployed like so:

Save the deployed contract addresses somewhere permanente

Deployed Addresses

OPZKGameModule#MultiSender - 0x5FbDB2315678afecb367f032d93F642f64180aa3
ZkwasmVerifier#AggregatorVerifierCoreStep1 - 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
ZkwasmVerifier#AggregatorVerifierCoreStep2 - 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
ZkwasmVerifier#AggregatorVerifierCoreStep3 - 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
ZkwasmVerifier#AggregatorVerifier - 0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9
OPZKGameModule#SpinOPZKGameContract - 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
OPZKGameModule#SpinGameRegistryContract - 0x61c36a8d610163660E21a8b7359e1Cac0C9133e1
OPZKGameModule#StakingContract - 0x23dB4a08f2272df049a4932a4Cc3A6Dc1002B33E

SpinOPZKGameContract is the contract we'll interact with the most.

Last updated