Skip to content

dotrungkien/eth-cocos-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to eth-cocos-code-base 👋

Version License: MIT

code base for Cocos Creator with Ethereum smart contract connection

Author

👤 KienDT

Prerequisite

Instructions

Contract deployment

  • Compile SimpleStore smart contract
cd contract/
yarn
npx hardhat compile
  • run a local blockchain node, then copy a private key and import it to Metamask, make sure you choose Localhost 8545 as network on Metamask and see 10000 ETH in account balance.
npx hardhat node

import-account-to-metamask

  • change the network id on Metamask to 31337 (if needed)

change-network-id

  • deploy Simple Storage to local blockchain node.
npx hardhat run scripts/deploy.js --network localhost
  • then save deployed address, for example: 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9

Cocos intergration

  • Copy abi file from contract/artifacts/SimpleStore.sol/SimpleStore.json to game/assets/contracts

  • change contractAddress in game/assets/Script/HelloWorld.js by the address of Simple Store you deployed above

  • run scene, change value and confirm transaction

confirm-tx

  • finally, transaction completed

tx-ok

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

About

code base for Cocos Creator with Ethereum smart contract connection

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published