/cybercontracts

Primary LanguageSolidityGNU General Public License v3.0GPL-3.0

test

CyberConnect Contracts

This hosts all contracts for CyberConnect's social graph protocol.

Some opinionated design decisions:

  1. Prefer require for semantic clarity.
  2. No custom error until require supports custom error.
  3. Try to be gas efficient :)

Dependencies

Foundry (book) slither

ABI

ABI

Set Up

  1. Upgrade your foundry foundryup

  2. To enable husky pre-commit yarn && yarn prepare

  3. To install contract dependencies forge install

  4. To build forge build

  5. To test forge test -vvv

  6. (optional) To run static analysis slither src/

  7. To see contract sizes yarn size

Deployment:

(Replace rinkeby with anvil or other supported network) 0. Create .env.rinkeby file with following env

# .env.pinata
PINATA_JWT=
# .env.rinkeby
RINKEBY_RPC_URL=
PRIVATE_KEY=
ETHERSCAN_KEY=

for local deployment in .env.anvil

# .env.anvil
PRIVATE_KEY=
PINATA_JWT=
  1. Deploy Actions first with npx hardhat run --network goerli hardhat-scripts/deployActions.ts
  2. You need a Create2Deployer to start the deployment. If you don't have a contract address, run yarn deploy_deployer:goerli or change deployerContract address in Deploy.s.sol to 0 to let the script deploy. Take down the deployer contract address
  3. Run yarn deploy:goerli or yarn deploy:anvil for local deployment. If you run into any unconfirmed txs, run yarn deploy:rinkeby --resume to continue. This also verifies contract on etherscan. Check profile proxy address log to make sure it's the same as step 0. Otherwise, abort. (This manual step will be fixed)
  4. Run yarn post_deploy to update ABI changes
  5. Run yarn upload_animation:goerli to upload animation uri for link3 to ipfs.
  6. Check DeploySetting.sol and make sure the deployer contract is correctly set as shown in docs/deploy/<network>/contract.md. Run yarn set_animation_url:goerli to deploy link3 nft descriptor with animation url. Then set to profile.

Verify on Etherscan

Because we use create2 for deployments, so we need to manually submit verification.

  1. Verify CyberEngineImpl
forge verify-contract --chain-id 5 --num-of-optimizations 200 <address> src/core/CyberEngine.sol:CyberEngine  $ETHERSCAN_KEY
  1. Verify CyberEngineProxy

a. find the init_data

bytes memory data = abi.encodeWithSelector(
   CyberEngine.initialize.selector,
   address(0),
   authority
);
console.logBytes(data);

b. verify

forge verify-contract --chain-id 5 --num-of-optimizations 200 <address> lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy --constructor-args $(cast abi-encode "constructor(address,bytes)" <impl_address> <init_data>)  $ETHERSCAN_KEY
  1. Verify Profile

Tests

QRCode

License

GNU General Public License v3.0 or later

See COPYING to see the full text.