- This library is a go implementation of a client for the TFChain.
- Internally, our own fork of https://github.com/centrifuge/go-substrate-rpc-client is used to make substrate rpc calls.
- Used in multiple repos like zos, rmb-go, and terraform-provider-grid.
To make substrate calls:
-
First, start a substrate connection against the desired url for the chain:
manager := NewManager("wss://tfchain.grid.tf/ws") substrateConnection, err := manager.Substrate()
-
These are the urls for different chain networks:
- devnet: wss://tfchain.dev.grid.tf/ws
- testnet: wss://tfchain.test.grid.tf/ws
- qanet: wss://tfchain.qa.grid.tf/ws
- mainnet: wss://tfchain.grid.tf/ws
-
It is the user's responsibility to close the connection.
defer substrateConnection.Close()
-
Then, a user could use the provided api calls to communicate with the chain. like:
contractID, err := substrateConnection.CreateNodeContract(identity, nodeID, body, hash, publicIPsCount, solutionProviderID)
-
Also, if a connection is closed for some reason like timing out, internally, it is reopened if nothing blocks.
-
All provided api calls are found under the Substrate struct.
To run the tests, you could either run it against a local docker image of the TFChain, or against devnet
-
To run tests against a local docker image of tfchain, you need to set CI environment variable to anything actually.
docker run -d -p 9944:9944 threefolddev/tfchain:2.2.0-rc8 --dev --rpc-external sleep 3 export CI="true" go test . -v
-
unset CI go test . -v
- 30.6% of statements