Skip to content

liangkuaiqian/safe-contracts

Repository files navigation

Gnosis Safe Contracts

npm version Build Status

Install

Install requirements with yarn:

yarn

Run all tests (requires Node version >=7 for async/await):

yarn truffle compile
yarn test

yarn test will start a ganache-cli with the correct configuration. If you want to run yarn truffle test you need to start a ganache-cli instance. For this it is required to use the --noVMErrorsOnRPCResponse option. This option will make sure that ganache-cli behaves the same as other clients (e.g. geth and parity) when handling reverting calls to contracts. This is required as some flows parse the error message (see https://gnosis-safe.readthedocs.io/en/latest/contracts/transactions.html#safe-transaction-gas-limit-estimation).

Deploy

Some contracts require that the Solidity compile target is at least petersburg (e.g. GnosisSafeProxyFactory and MultiSend). This is default since Solidity 0.5.5.

Note: The formal verification was performed using the contract compiled with solcjs 0.5.0.

Preparation:

  • Set INFURA_TOKEN in .env
  • Set NETWORK in .env
  • Run yarn truffle compile

Truffle:

  • Set MNEMONIC in .env
yarn truffle deploy

Verify Contracts:

  • requires installed solc (>0.5.0)
virtualenv env -p python3
. env/bin/activate
pip install solidity-flattener
mkdir build/flattened_contracts
solidity_flattener contracts/GnosisSafe.sol --output build/flattened_contracts/GnosisSafe.sol
solidity_flattener contracts/libraries/CreateAndAddModules.sol --output build/flattened_contracts/CreateAndAddModules.sol --solc-paths="/=/"
solidity_flattener contracts/libraries/CreateCall.sol --output build/flattened_contracts/CreateCall.sol --solc-paths="/=/"
solidity_flattener contracts/libraries/MultiSend.sol --output build/flattened_contracts/MultiSend.sol --solc-paths="/=/"
solidity_flattener contracts/handler/DefaultCallbackHandler.sol --output build/flattened_contracts/DefaultCallbackHandler.sol --solc-paths="/=/"
solidity_flattener contracts/modules/DailyLimitModule.sol --output build/flattened_contracts/DailyLimitModule.sol --solc-paths="/=/"
solidity_flattener contracts/modules/SocialRecoveryModule.sol --output build/flattened_contracts/SocialRecoveryModule.sol --solc-paths="/=/"
solidity_flattener contracts/modules/StateChannelModule.sol --output build/flattened_contracts/StateChannelModule.sol --solc-paths="/=/"
solidity_flattener contracts/modules/WhitelistModule.sol --output build/flattened_contracts/WhitelistModule.sol --solc-paths="/=/"
solidity_flattener contracts/proxies/GnosisSafeProxyFactory.sol --output build/flattened_contracts/GnosisSafeProxyFactory.sol
find build/flattened_contracts -name '*.sol' -exec sed -i '' 's/pragma solidity ^0.4.13;/pragma solidity >=0.5.0 <0.7.0;/g' {} \;

Verify contract

Note: For this it is required that the project path is /gnosis-safe this can be archived using sudo mount -B <your_repo_path> gnosis-safe. Make sure the run yarn prepare again if the path has been changed after the inital yarn install.

You can locally verify contract using the scripts generate_meta.js and verify_deployment.js.

With node scripts/generate_meta.js a meta folder is created in the build folder that contains all files required to verify the source code on https://verification.komputing.org/

Once the meta data has been generated you can verify that your local compiled code corresponds to the version deployed by Gnosis with yarn do <network> scripts/verify_deployment.js.

Documentation

Audits/ Formal Verification

Security and Liability

All contracts are WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

License

All smart contracts are released under LGPL v.3.

Contributors

About

Safe allows secure management of blockchain assets.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 64.5%
  • Solidity 27.2%
  • JavaScript 8.2%
  • Shell 0.1%