Git Product home page Git Product logo

cybercontracts's Introduction

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.

cybercontracts's People

Contributors

akasuv avatar jiayi1992 avatar karmax-x avatar omahs avatar pengdeng-cyber avatar pusongqi avatar ryanli-me avatar samixdev avatar santiago0412 avatar snowdot avatar zhimaol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.