Giter Club home page Giter Club logo

ethereum-smart-contracts's Introduction

IOV's smart contracts for Ethereum

Build system

The truffle build system uses a different artifacts directory for compiling (a) and testing (b). We prepand a custom flattening step.

Step 1

Implicit yarn flatten flattens contracts from ./contracts into ./build/flattened.

Step 2a

yarn build compiles contracts from ./build/flattened into ./build/contracts.

Step 2b

yarn test compiles contracts from ./build/flattened into a temporary folder.

ethereum-smart-contracts's People

Contributors

willclarktech avatar webmaster128 avatar merge-when-green[bot] avatar

Stargazers

 avatar just do it avatar C H avatar Jeff Wentworth avatar

Watchers

James Cloos avatar  avatar Anna Torok avatar  avatar

Forkers

wdcodecn

ethereum-smart-contracts's Issues

Setup CI

Tests should run on travis before PR merge

Ensure every account can claim/abort

In iov-one/iov-core@da10566 we explicitly allow every account willing to spend transaction fees to claim or abort a swap. We should verify this is implemented and add 4 tests ensuring this property.

  • Every account can Eth/claim
  • Every account can Eth/abort
  • Every account can Erc20/claim
  • Every account can Erc20/abort

Deploy smart contract given ABI and bytecode

Builds on #2

With web3, you can connect to a contract via:
let contract = web3.eth.contract(PASTE ABI HERE!);

And set the bytecode once via:
contract.new({from.., gas..., data: "PASTE_HEX_BYTECODE_HERE"})

We should upload via iov-core/iov-etherum code.
At this stage we can use web3/truffle/etc tooling to validate the data is properly writen to the blockchain, by querying the address.

Acceptance Criteria

  • Given ABI and Bytecode, and an account with some funds, upload contract to ganache
  • Create a iov-ethereum specific UnsignedTransaction to represent this (CreateContractTransaction ?)
  • Validate the contract can be viewed via web3 and the bytecode is properly stored.

Setup smart contract repo

  • Apache-2 licence (copy from iov core)
  • No external contributors
  • Rewrite contract from scratch
  • TDD?
  • Focus on Ether only first
  • Renaming
  • Events in past tense
  • Move state into struct
  • Combine check and checkSecret
  • Remove Pausable
  • Linting
  • Look into etheno [not necessary for now]
  • Analysis scripts (slither, manticore, truffle-security)
  • Truffle/ganache
  • CI setup (especially for linting)

Add amount and sender to Opened event

If we include amount and sender as well, we can watch logs and let the client show new swap offers without an extra query., similar to BNS:

  public swapOfferFromTx(confirmed: ConfirmedTransaction<SwapOfferTransaction>): OpenSwap {
    const transaction = confirmed.transaction;
    return {
      kind: SwapState.Open,
      data: {
        id: confirmed.result as SwapIdBytes,
        sender: identityToAddress(transaction.creator),
        recipient: transaction.recipient,
        hash: transaction.hash,
        amounts: transaction.amounts,
        timeout: transaction.timeout,
        memo: transaction.memo,
      },
    };
  }

but with watching logs instead of watching transactions

Helper scripts to compile Solidity to bytecode

When adding custom contracts to the ethereum chain (or our test chain), we will need to compile some human-readable solidity into evm bytecode, so it can be uploaded.

truffle toolkit will compile and upload together. We should choose and document some tools we can use to compile into one file that we can upload separately.

Acceptance Criteria

  • Add description of the tooling to a README in iov-ethereum package (we can also extend section on ganache)
  • Copy a reference erc20 contract to a folder under scripts/ethereum for tests
  • Add a script to scripts/ethereum to compile this contract and save the output in another directory
  • Make sure to expose the ABI (method definitions) as well as the raw bytecode

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.