Set up development environment
Before development, it is necessary to configure your nodes, servers, and local environment. These configurations are important and require careful reading.
The interfaces provided in this chapter are all applicable to versions v0.22.2
and above.
The data type returned by the interface is in json format.
1. Run your Transformers node
For how to quickly run transformer nodes, see the Run a Validator.
2. Enable RPC interface
Before starting the program, first open the configuration file config.json
, refer to the following configuration
{
"http_callback": {
"ip": "",
"path": "",
"port": 0
},
"http_port": 20620,//The port defaults to 20620
"info": {
"logo": "",
"name": ""
},
"ip": "",//Fill in the external network ip here, it is not that the external network cannot be connected
"log": {
"console": false,
"level": "OFF",
"path": "./logs"
},
"rpc": true,//rpc must be set to true, otherwise the rpc interface cannot be adjusted.
"server": [//Fill in the scout node here
],
"server_port": 20619,//The port defaults to 41516
"version": "1.0"
}
If you need to enable rpc power supply, please modify the config.json file and set rpc
to true
"rpc": true,
The content of http_port
configuration is the port requested by the rpc
"http_port": 20620,
3. Set up server security groups
Open the interface of your server security group to ensure that you can request the RPC interface.
By completing the above three steps, you can perform block,Account,Network information query on the node.
4. Compile the official SDK
If you want to perform operations such as transfers, investments, disinvestments, staking, unstaking, contract deployment, and contract execution, you will need to use the methods provided within the official SDK.
The program can be logged in to Transformers Labs (github.com) to pull the code and compile it.
Installation dependencies && compile
You need to compile the full OpenSSL and Protobuf
- Download OpenSSL-3.0.5
tar -xvf openssl-3.0.5.tar.gz
cd openssl-3.0.5
./Configure
make && make install
- Download Protobuf-CPP-3.21.9
unzip protobuf-cpp-3.21.9
cd protobuf-cpp-3.21.9
cd cmake && mkdir build
cd build
cmake .. && make && make install
- compile SDK
cd rpc_lib
cd build
cmake ..
After compilation, the corresponding dynamic library for the environment will appear in the build directory.
SDK interface description
The following is a list of important method names in the SDK.
/*Get the private key handle from private key base64*/
long long import_base64_prikey_handler(const char *buf, int buf_size);
/*Get a new base64 private key*/
char *export_new_prikey_base64();
/*Get the private key handle from private key base 16*/
long long import_prikey_handler_from_hex(const char *str);
/*Get a new base 16 private key*/
char *export_new_prikey_to_hex(long long pkey);
/*Export mnemonic phrase from private key handle*/
char *export_mnemonic_from_prikey_handler(long long pkey);
/*Get private key handle from mnemonic phrase*/
long long import_prikey_handler_from_mnemonic(const char *mnemonic);
/*Get base58 from private key handle*/
char *get_base58addr(long long pkey);
/*Get the public key base64 from the private key handle*/
char *get_pubstr_base64(long long pkey);
/*Sign transactions using a private key handle*/
char *sig_tx(long long pkey, const char *message, int msize);
/*Release the private key handle*/
void free_prikey_handler(long long pkey);
/*Get base58 from EVM address*/
char * get_base58_from_evm(const char * evmAddr);
/*Get EVM address from public key*/
char *get_evmaddr_from_pubstr(const char * pubstr,int pubstr_size);
How to use?
- Generate wallet addresses and corresponding private keys, public keys, mnemonics, and EVM addresses using the methods provided in the SDK.
- Fill in the request JSON in the fixed format of each rpc_api, and call rpc_api to get the transaction body.
- Use RPC SDK to sign the transaction body and call the
send_message
interface to broadcast the transaction