Installation and usage of the platform
Development and usage of smart contracts¶
The definition and general description of how smart contracts work on the Waves Enterprise blockchain platform are provided in the article Smart contracts.
Preparing to work¶
Before you start developing a smart contract, make sure that you have the Docker containerization software package installed on your machine. The principles of working with Docker are described in the official documentation.
Also make sure that the node you are using is configured for smart contract execution . If your node is running in the Waves Enterprise Mainnet, it is configured by default to install smart contacts from the open repository and has the recommended settings to ensure optimal smart contact execution.
If you are developing a smart contract to run on a private network, deploy your own registry for Docker images and specify its address and credentials on your server in the remote-registries
block of the node configuration file. You can specify multiple repositories in this block if you need to define multiple storage locations for different smart contracts. You can also load a Docker contract image from a repository not specified in the node configuration file using transaction 103, which initiates the creation of a smart contract. For more information, see Development and installation of a smart contract and description of the transaction 103.
When working in the Waves Enterprise Mainnet, the Waves Enterprise open registry is pre-installed in the configuration file.
Smart contract development¶
Waves Enterprise blockchain platform smart contracts can be developed in any programming language you prefer and implement any algorithms. The finished smart contract code is packaged in a Docker image with smart contract authorization parameters (when using REST API) or used protobuf files (when using gRPC).
Examples of Python smart contract code using gRPC and REST API methods to exchange data with a node, as well as a step-by-step guide on how to create the corresponding Docker images are given in the following articles:
You can use JS Сontract SDK Toolkit and Java/Kotlin Сontract SDK Toolkit to develop, test and deploy smart contracts in Waves Enterprise public blockchain networks. These toolkits are described in the following sections:
Uploading of a smart contract into a registry¶
Contact the Waves Enterprise Technical Support team to place your smart contract in the public repository if you are working in the Waves Enterprise Mainnet.
When working on a private network, upload a Docker image of the smart contract to your own registry:
1. Start your registry in a container:
docker run -d -p 5000:5000 --name my-registry-container my-registry:2
2. Navigate to the directory containing the smart contract files and the Dockerfile script file with commands for building the image.
3. Build an image of your smart contract:
docker build -t my-contract .
4. Specify the image name and its location address in the repository:
docker image tag my-contract my-registry:5000/my-contract
5. Run the repository container you created:
docker start my-registry-container
6. Upload your smart contract to the repository:
docker push my-registry:5000/my-contract
7. Get information about the smart contract. To do this, display the information about the container:
docker image ls|grep 'my-node:5000/my-contract'
This will give you the ID of the container. Output the information about it with the docker inspect
command:
docker inspect my-contract-id
Response example:
{
"Id": "sha256:57c2c2d2643da042ef8dd80010632ffdd11e3d2e3f85c20c31dce838073614dd",
"RepoTags": [
"wenode:latest"
],
"RepoDigests": [],
"Parent": "sha256:d91d2307057bf3bb5bd9d364f16cd3d7eda3b58edf2686e1944bcc7133f07913",
"Comment": "",
"Created": "2019-10-25T14:15:03.856072509Z",
"Container": "",
"ContainerConfig": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
The Id
field is the identifier of the Docker image of the smart contract, which is entered in the ImageHash
field of 103 transaction when creating the smart contract.
Installing of a smart contract into the blockchain¶
After uploading the smart contract to the repository, install it on the network using the 103 transaction. To do this, sign the transaction via the blockchain platform client, the sign
REST API method or the JavaScript SDK method.
The data returned in the method’s response is fed into transaction 103 when it is published.
Below, you will see the examples of signing and sending a transaction using the sign
and broadcast
methods. In the examples, the transactions are signed with the key stored in the keystore of the node.
Smart contract execution¶
Once a smart contract is installed in the blockchain, it can be invoked with a 104 CallContract Transaction.
This transaction can also be signed and sent to the blockchain via the blockchain platform client, the sign
REST API method or the JavaScript SDK method. When signing a transaction 104, specify the ID of the 103 transaction for the called smart contract in the contractId
field (the id
field of the sign
method response).
Examples of signing and sending a transaction using the sign
and broadcast
methods using a key stored in the keystore of a node: