/furry-train

Primary LanguageSolidity

Minimini Hokusai

Set up

Create docker network

docker network create hokusai-network

Usage

Run containers

docker-compose up

Clean up containers

docker-compose down

Hardhat

use the Ethers.js and Waffle plugins.

usage

compile

The hardhat-typechain is also automatically executed at this time.

yarn hardhat compile

test

yarn hardhat test 

about web3/contracts/Profile.compiled.json

  • Generation
    1. yarn hardhat compile
    2. A cache directory and an artifacts directory are generated.
      (cacheディレクトリとartifactsディレクトリが生成されます)
    3. Move & rename Profile.json generated in contracts directory .
      (contractsディレクトリ内に生成されるProfile.jsonを移動 & rename)

usage Profile Contract

  1. Activate hardhat node in web3 container
docker exec web3 npx hardhat node
  1. Deploy contract and get contract address
curl --location --request POST 'http://localhost:8080/v1/0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266/profile' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Bob",
    "email": "bob@example.com"
}'
  1. Get contract information including {Contract address obtained in 2}
curl --location --request GET 'http://localhost:8080/v1/0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266/profile/{Contract address obtained in 2}' \
--header 'Content-Type: application/json'

about ProfileFactory class

  • Contract Factory Class generated by hardhat-typechain.

  • The hardhat-typechain will generate it with abi and bytecode inside. Therefore, there is no need to set the compiled abi and bytecode by yourself. (内部にabiとbytecodeを持った状態でhardhat-typechain が生成してくれる。 なので、compileしたabiとbytecodeを自分で設定する必要がない。)

  • If not used, it is necessary to import abi and bytecode from the json generated by compiling contract. (もし使用しない場合、contractをcompileして生成されたjsonから、abiとbytecodeをimportする必要がある。)