Coder Social home page Coder Social logo

blockchain-development-resources / ds-proxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dapphub/ds-proxy

0.0 1.0 0.0 94 KB

a proxy object that can compose transactions on owner's behalf

Home Page: https://dapp.tools/dappsys/ds-proxy.html

License: GNU General Public License v3.0

Makefile 20.00% Nix 80.00%

ds-proxy's Introduction

DSProxy

Execute transactions & sequences of transactions by proxy

This contract implements a very useful utility called a proxy. It is deployed as a standalone contract, and can then be used by the owner to execute code.

A user would pass in the bytecode for the contract as well as the calldata for the function they want to execute.

The proxy will create a contract using the bytecode. It will then delegatecall the function and arguments specified in the calldata. Loading in this code is more efficient than jumping to it.

Use Cases

1. Allow actions to be executed through the proxy identity

This can be very useful for securing complex applications. Because delegatecall retains msg.sender and msg.value properties, internal functions can be set to only accept calls coming from the proxy through an ownership model like ds-auth. In this manner as long as the proxy is not compromised, the internal system is protected from outsider access. Should the owner of the internal calls ever need to be changed, this is as simple as updating the owner of ds-proxy rather than manually updating each individual internal function call, making it much more secure and adaptable.

2. Execute a sequence of actions atomically

Due to restrictions in the EVM instruction set such as being unable to be nested dynamically sized types and arguments, 1 transaction could be done at a time. Since ds-proxy takes in bytecode of a contract, rather than relying on a pre-deployed contract, customized script contracts can be used. These script contracts share a very a important property in that they enable a sequence of actions to be executed atomically (all or nothing). This prevents having to manually rollback writes to contracts when a single transaction fails in a set of transactions.

Example Usage

Note: the examples assume the user is using Dapphub's dapp and seth

  1. Deploy DSProxyFactory. (Optional - DSProxy can be deployed directly)

    dapp create DSProxyFactory

  2. Call the build function in DSProxyFactory to create a proxy for you. (Optional)

    seth send <DSProxyFactoryAddr> "build()(address)"

  3. Create a contract and compile using solc.

    dapp build MyCustomContract

  4. Get the calldata for the function and arguments you want to execute

    seth calldata "<functionName>(<argType1>,<argType2>...<argTypeN>)(<returnArgType>)" <arg1> <arg2> <argN>

  5. Pass the contract bytecode and calldata to the execute function inside the deployed DSProxy.
    seth send <DSProxyAddr> "execute(bytes,bytes)(bytes32)" <ContractByteCode> <CallData>

ds-proxy's People

Contributors

apmilen avatar asymmetric avatar desaperados avatar gbalabasquer avatar mbrock avatar mrchico avatar nanexcool avatar nmushegian avatar rainbreak avatar

Watchers

 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.