https://github.com/dragonchain/smart-contract-templates
Some starter templates for Dragonchain smart contracts in various languages
https://github.com/dragonchain/smart-contract-templates
blockchain blockchain-technology docker dragonchain dragonchain-smart-contract smart-contract-template smart-contracts templates
Last synced: 3 months ago
JSON representation
Some starter templates for Dragonchain smart contracts in various languages
- Host: GitHub
- URL: https://github.com/dragonchain/smart-contract-templates
- Owner: dragonchain
- License: apache-2.0
- Created: 2019-10-09T19:00:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-22T09:44:14.000Z (about 3 years ago)
- Last Synced: 2024-08-03T22:24:18.388Z (7 months ago)
- Topics: blockchain, blockchain-technology, docker, dragonchain, dragonchain-smart-contract, smart-contract-template, smart-contracts, templates
- Language: JavaScript
- Size: 49.8 KB
- Stars: 2
- Watchers: 10
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.MD
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - dragonchain/smart-contract-templates - Some starter templates for Dragonchain smart contracts in various languages (JavaScript)
README
# 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
```sh
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:
```sh
docker build . -t me/my-contract:0.0.1
```Then use [DCTL](https://github.com/dragonchain/dctl) to test with a dragonchain transaction.
```sh
# 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](./CONTRIBUTING.md) docs for more info.