Giter VIP home page Giter VIP logo

splitter's Introduction

Splitter

A serpent contract for preventing replay attacks.

When a blockchain forks, every account that had funds before the fork now has funds on both of the forks. If the clients on each fork still use the same transaction format, then transactions meant for only one chain can change the state of a different chain as well. This is call a replay attack.

This contract solves this problem by creating internal account identifiers(here on simply called accounts) which depend on a specific block hash. This results in accounts which are different on different blockchains. The contract also updates the block hash it uses to create accounts (about once a month), meaning that in the event of future forks, you can use the same method to move your funds again.

API

This contract provides the following functions for safely transfering money to a new account. All input arguments and outputs have the ABI type int256.

  • blocks_till_update()

    • This function takes no arguments, and returns the number of blocks till the block hash used for making accounts gets updated.
  • new_account()

    • This function creates an new account by hashing (sha3) the sender's address concatenated to a specific block hash. The new account is returned, and is also logged.
  • deposit(account)

    • This function updates an internal value to keep track of money sent to the contract. It only works if the account specified is owned by the sender. This returns 0 if the sender does not own the account, and 1 if the transaction succeeded. It logs the amount deposited and the new balance.
  • get_balance(account)

    • This function returns the ammount deposited to this account.
  • withdraw(account, to)

    • This function withdraws all funds from the account to a new address, and deletes the account. This function only works if called by the address which created the account. On failure, returns 0, otherwise logs the amount of funds sent and the receipt address, and returns 1.

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.