GithubHelp home page GithubHelp logo

dragonchain / smart-contract-templates Goto Github PK

View Code? Open in Web Editor NEW
2.0 10.0 4.0 51 KB

Some starter templates for Dragonchain smart contracts in various languages

License: Apache License 2.0

Dockerfile 21.62% Shell 3.83% C 11.31% C++ 9.88% C# 9.06% Go 5.03% JavaScript 33.01% Python 6.27%
dragonchain smart-contracts templates docker blockchain blockchain-technology dragonchain-smart-contract smart-contract-template

smart-contract-templates's Introduction

Dragonchain Smart Contract Templates

Dragonchain smart contracts use docker containers and stdin/stdout for input/output.

In order to help get started, some templates are provided in various languages to demo setting up the input/output/logging aspects of a smart contract, as well as its associated Dockerfile for building.

Making A Smart Contract

In order to run a smart contract on Dragonchain, it must be packaged in a Docker container for the linux platform with x86-64 architecture. This means that a Dockerfile shoud be used to assist in building the container with the code.

Please note that Dragonchain smart contracts will always run as user 1000:1000, so it can be useful to add this to the end of your Dockerfile for testing purposes. (See any of the templates in this repository for any example).

Handling Input/Output/Logging

Dragonchain smart contracts use stdin for input, stdout for output, and stderr for logging purposes.

The templates provided in various languages here demo setting up a contract to be able to handle this.

Getting started

Clone the repository locally to copy any of the template contracts

git clone https://github.com/dragonchain/smart-contract-templates

Then simply use and modify a contract for any language you wish.

Testing Your Contract

In order to test your contract, first build it into a tagged docker container:

docker build . -t me/my-contract:0.0.1

Then use DCTL to test with a dragonchain transaction.

# Node contract
START_COMMAND=$(cat ./config.json | jq '.startCommand')
dctl contract test me/my-contract:0.0.1 $START_COMMAND --payload 'hi' -t 'MytxnTag'

Contributing

We are happy to take pull requests to add new language templates, or modify existing ones if necessary. Read the contributing docs for more info.

smart-contract-templates's People

Contributors

cheeseandcereal avatar cosmosinnovate avatar daadaadragon avatar deanshelton913 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.