An autonomous agent that operates on behalf of the issuer to recognize and enforce some or all the terms and conditions of the specified contract. At a minimum, the Smart Contract operates within the bounds of the Tokenized Protocol on the Bitcoin SV (BSV) network. The Smart Contract is written in Go and is intended to offer all the basic functionality required to issue, manage and exchange tokens, but it can also be used as the basis for much more complex smart contracts.
This is an Alpha release, with more changes likely before the final version. Do not use this in production.
If you're only ever going to run the binary and are not interested in working with the source code.
go get github.com/tokenized/smart-contract/cmd/...
To build the project from source, clone the GitHub repo and in a command line terminal.
mkdir -p $GOPATH/src/github.com/tokenized
cd $GOPATH/src/github.com/tokenized
git clone git@github.com:tokenized/smart-contract
cd smart-contract
Navigate to the root directory and run:
make
Configuration is supplied via environment variables. See the example file that would export environment variables on Linux and macOS.
Make a copy the example file, and edit the values to suit. The file can be placed anywhere if you prefer.
cp conf/dev.env.example ~/.contract/acme.env
The following configuration values are needed:
OPERATOR_NAMEthe name of the operator of the smart contract. Eg: ACME CorporationVERSIONFEE_ADDRESSpublic address to earn fees upon every actionFEE_VALUEthe cost in satoshis to perform an action (<2000 at this stage)
NODE_ADDRESShostname or IP address for a public nodeNODE_USER_AGENTthe user agent to provide when connecting to the public nodeRPC_HOSThostname or IP address for a private node (RPC)RPC_USERNAMEusername for RPC authenticationRPC_PASSWORDpassword for RPC authenticationPRIV_KEYprivate key (WIF) used by the smart contract
CONTRACT_STORAGE_REGIONS3 region for data storageCONTRACT_STORAGE_ACCESS_KEYS3 access key for data storageCONTRACT_STORAGE_SECRETS3 secret for data storageCONTRACT_STORAGE_BUCKETbucket for data storage, use standalone for local filesystemCONTRACT_STORAGE_ROOTroot directory for storage
NODE_STORAGE_REGIONS3 region for data storageNODE_STORAGE_ACCESS_KEYS3 access key for data storageNODE_STORAGE_SECRETS3 secret for data storageNODE_STORAGE_BUCKETbucket for data storage, use standalone for local filesystemNODE_STORAGE_ROOTroot directory for storage
This example shows the config file containing the environment variables
residing at ./conf/dev.env.example:
source ./conf/dev.env.example && make run
The Smart Contract requires RPC access to a full bitcoin node, such as Bitcoin SV. Once installed and syncronised with the BCH network, ensure that RPC is enabled by modifying the bitcoin.conf file.
# bitcoin.conf
server=1
rpuser=someUserName
rpcpassword=somePassword
rpcport=8332
To perform unit tests run:
make test
See the deploy directory for information on how to deploy the smart contract.
Copyright 2018 nChain Holdings Limited.