Skip to content

ubisoft/genesis-contracts

Repository files navigation

Genesis Contracts

Smart contracts for Champions Tactics™ Grimoria Chronicles written in Solidity.

Champions Tactics™ Grimoria Chronicles is a PVP Tactical RPG game on PC by Ubisoft. Assemble a team of mythical Champions and craft you legend in the dark and mystical world of Grimoria.

Architecture

For a global overview of the contracts, refer to the diagram below

Architecture diagram

Security

GenesisPFP is deployed on Ethereum mainnet at address 0xE841e6e68BECFC54b621A23a41f8C1a829a4cf44 and has been audited by KALOS. The report can be found here.

GenesisChampionFactory, GenesisChampion, GenesisMinter, GenesisCrafter, GenesisRewardsDistributor, GenesisCrafterRule have been audited by Halborn. The report can be found here.

Deployments

Please find below the addresses of deployed contracts:

Contract name Contract address Network
GenesisPFP 0xE841e6e68BECFC54b621A23a41f8C1a829a4cf44 Ethereum mainnet
GenesisChampion 0x9d13bddc0e8e19a2a4a88a5a39fe0c12f005fa16 Oasys Homeverse
GenesisChampionFactory 0xfb6d4eccab107bfdbfd6ee78668acda3b55c2ace Oasys Homeverse
GenesisMinter 0xe92e9adb3056cd7afc08ae4550ea8db972d0388b Oasys Homeverse
AuthenticatedRelay 0x89806ee417308debd454c24d0e5b9da3ee93dd07 Oasys Homeverse

Slither reports

Installation

From source

  1. Install Foundry
  2. Clone this repository
  3. Initialize the submodules
# when switching branch, it's recommended to deinit the submodules first with:
# git submodule deinit --force .
git submodule update --init --recursive
  1. Install external dependencies for lib/authenticated-relay (see README.md)
cd lib/authenticated-relay
forge install
# build sequence contracts dependencies:
pushd lib/contracts-library
yarn && yarn build
popd
  1. Install node dependencies: npm install

Contract documentation

Contract documentation is auto-generated using forge doc.

forge doc -s allows you to serve it locally at localhost:3000.

Build, test and deploy

Build

forge build

Test

forge clean && forge test --ffi --force --summary --detailed

GenesisCrafter and GenesisMinter use openzeppelin-foundry-upgrades to make safety checks before upgrading proxy implementations, we need to use the --ffi flag that will run external processes (i.e. shell scripts) from Solidity code.

Deploy

Deploying Locally

  1. Start a local testnet using anvil or any local testnet client
  2. In another terminal, setup the required env variables and run forge create to deploy the contract as below

Use the --unlocked flag with Anvil's first test account used as sender with ETH_FROM

For GenesisPFP

export ETH_FROM="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
export MINTER_ADDRESS="0x..."
export VAULT_ADDRESS="0x..."
export LINK_ADDRESS="0x0000000000000000000000000000000000000000"
export VRF_WRAPPER_ADDRESS="0x0000000000000000000000000000000000000000"
export RPC_URL="http://localhost:8545" # Anvil local RPC

forge create                                    \
    --rpc-url $RPC_URL --unlocked               \
    src/GenesisPFP.sol:GenesisPFP               \
    --constructor-args "Genesis PFP" "PFP" "1"  \
        $MINTER_ADDRESS $VAULT_ADDRESS          \
        $LINK_ADDRESS $VRF_WRAPPER_ADDRESS
source ./script/GenesisChampionFactory/anvil.env
forge script script/GenesisChampionFactory/Deploy.s.sol --sig "deploy()" --rpc-url http://localhost:8545 --broadcast

# GenesisChampionFactory deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3
✅  [Success]Hash: 0x5fc8eb0e8498bf7c5dae6f6884a27a1c7d083288b28878f2062dc7e3f8784165
Contract Address: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Block: 1
Paid: 0.016042904 ETH (4010726 gas * 4 gwei)

# GenesisChampion implementation deployed using `GenesisChampionFactory.deploy()`
✅  [Success]Hash: 0x9da0f622ce953256f5d0bddac9849bfd6b0baf78785bfef7aa4ccb385894777d
Block: 2
Paid: 0.011808357309540703 ETH (3021259 gas * 3.908422717 gwei)

# Implementation address can be called using cast
cast call 0x5fbdb2315678afecb367f032d93f642f64180aa3 "getLatestDeployment()"
0x000000000000000000000000a16e02e87b7454126e5e10d957a927a7f5b5d2be

Deploy on a public network (GenesisPFP)

We use the Sepolia testnet to deploy and test our contracts in dev environment.

Chainlink's VRF configuration for Sepolia can be found here.

Deployment parameters are listed below in the same order as the contract constructor takes them:

Parameter Value
Name GenesisPFP
Symbol PFP
Version 1
Minter address Address granted with MINTER_ROLE on contract creation
Vault address Address receiving marketplace royalties
LINK Token 0x779877A7B0D9E8603169DdbD7836e478b4624789
VRF Wrapper 0xab18414CD93297B0d12ac29E63Ca20f515b3DB46

You will need to provide a mnemonic phrase, private key, ledger or any wallet solution to deploy your contract on a live network. Please refer to Foundry's documentation for options.

To deploy the contracts on Sepolia, run the following command (replace $RPC_URL with a valid Sepolia RPC endpoint):

$forge create                                    \
    --rpc-url $RPC_URL                  \
    src/GenesisPFP.sol:GenesisPFP               \
    --constructor-args "Genesis PFP" "PFP" "1"  \
        $MINTER_ADDRESS $VAULT_ADDRESS          \
        $LINK_ADDRESS $VRF_WRAPPER_ADDRESS

Authors

  • Nicolas LAW YIM WAN
  • Louis GAROCHE

License

This project is available under the Apache 2.0 License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages