Build VictorLink Nodes

This section describes how to join the VictorLink ecosystem: deploying an oracle contract and building a VictorLink node.
Currently, VictorLink does not distinguish between oracle contract owners and the oracle node operators. That is, the operator of the oracle node is also the owner of the oracle contract. The oracle node account only handles data sources and data submissions, and the oracle contract owner can invoke the contract and withdraw the usage fees paid by users of the oracle contract.

Preparation

VictorLink maintainers need to have some knowledge of the Vision chain and be familiar with the smart contract deployment and invocation process.

Contract Deployment

The VictorLink ecosystem is decentralized and all smart contracts are open source, allowing any organization or individual to deploy their own VictorLink oracle contracts and publish the services they offer to the public.
Users can create their own aggregated data contracts and benefit from decentralization by choosing their desired combination of the various publicly available VictorLink services.
The project contracts are located at: https://github.com/vision-consensus/victorlink/tree/master/vvm-contracts/v1.0
Contracts can be deployed and test calls can be made using any of the following tools or libraries.
Vision-wallet-client tool
VisionIDE, which also supports contract compilation
VisionBox, which also supports contract compilation
visionweb

VictorMid Contracts

VictorLink takes the VCT token (VRC20) as the base token for the entire ecosystem.
VictorLink relies on the transferAndCall function, which calls a callback function of the contract while transferring VRC20 tokens to the contract, similar to ERC677, but with different interface parameters.
Considering that most of the issued tokens cannot be modified to add interfaces to the contract, VictorLink provides the VictorMid contract, which can be used to wrap any VRC20 token and provides the transferAndCall interface.
The contract code is located at VictorMid.sol (https://github.com/vision-consensus/victorlink/blob/master/vvm-contracts/v1.0/VictorMid.sol).
For the convenience of developers, the Vpioneer Test Network has deployed the VictorMid contract, which encapsulates the Vpioneer Test Network VCT tokens. Developers can use this contract address directly without additional deployment. The Vpioneer Test Network also provides a tap address to receive test VS and VCT tokens.

The address of the encapsulated VRC20 token (i.e. VCT token address) needs to be provided in the constructor when deploying the VictorMid contract.
All operations on the VictorMid contract are performed in the contract, and developers do not need to call the contract directly

Oracle Contracts

Oracle Contracts are deployed on the TRON public chain. The main functions are as follows:

  1. Receiving data requests from Consumer Contract and trigger Event Log, and
    sending data requests with WIN transfer as usage fee

  2. Accepting data submitted by VictorLink nodes
    2.1) The VictorLink node is informed of the data request by listening to the Event Log
    2.2) The node identifies the job configuration, selects the adapter corresponding to the different data requests, obtains external data, and submits the data to the Oracle contract
    2.3) Triggering the data callback function of the consumer contract

  3. Supporting revocation of data requests

  4. Settlementing VCT token fees for data requests and extraction of revenue

The contract code is located at VisionOracles.sol (https://github.com/vision-consensus/victorlink/blob/master/vvm-contracts/v1.0/VisionOracles.sol).
Deploying an Oracle contract requires the VCT token address and VictorMid contract address to be provided in the constructor.
Oracle contracts implement the Ownable interface, which allows the owner of the contract to manage the proceeds or destroy the contract.

Node Deployment

Once the contract is deployed, you can start the VictorLink node deployment.
The VictorLink node (the project directory is “node”) is coded located at: https://github.com/vision-consensus/victorlink/tree/master/node

WARNING

The current node implementation includes an adapter for obtaining coin prices via the exchange API. Please run the node in a stable non-China network environment.

Preparing Node Accounts

Each VictorLink node must correspond to a VISION account, which is used to invoke the Oracle contract to submit data.
After generating the account address and private key, the developer casts a test VS token through the test network tap page. The token is used to pay the necessary fees for the smart contract invocation.
Developers can generate the account address and private key by any of the following methods
vision-wallet-client tool
Generate Address Offline

Environment Dependent

The VictorLink node depends on a MySQL instance. Developers can deploy MySQL instances using the target environment's package manager or Docker.

Tip

It is assumed that the username and password of the locally deployed MySQL instance are root:root, but in production environments please use strong passwords or other authentication methods.
The VictorLink node is written in Java and relies on the JRE/JDK environment, Oracle JDK8 is recommended.
The VictorLink node relies on a nodejs environment and requires nodejs(npm) >= 10.0 to be installed.

Getting the Node Executable

Developers can download the latest version of the VictorLink node executable, node-v1.0.jar, from the Github Release (https://github.com/vision-consensus/victorlink/) page.
You can also compile it as follows:

# Requires jdk8, and nodejs(npm) >= 10.0
git clone [email protected]:vision-consensus/victorlink.git
cd victorlink/

# Compile
. /gradlew build -x test

The node-v1.0.jar is located in node/build/libs/ in the project source directory after compilation.

Node Configuration

The VictorLink node is configured using the springboot method. All configuration files are located in the project subdirectory node/src/main/resource. application.yml can specify the specific profile to be used.

# application.yml
server:
    port: 8080
spring:
    # dev|pro
    profiles:
        active: dev # Set the specific profile file here, i.e. `application-dev.yml`
    jackson:
        time-zone: GMT+8
        date-format: yyyy-MM-dd HH:mm:ss
    servlet:
        multipart:
            maxRequestSize: 104857600 #100MB

# ... (omitted)

In application-[ACTIVE_PROFILE_NAME].yml you can specify the specific MySQL database connection configuration, the default dev uses the local instance and the username and password is root:root.
After confirming the node configuration file, you need to create a key.store file and write the private key of the node account:

privatekey=*****(32 bytes hex encoded private key)

Tip

It is an important security consideration to provide the private information through a file instead of command line parameters.

Starting The Node

All configuration files need to be copied to the current runtime directory of the node program, i.e. cp node/src/main/resource/*.yml . /.
Start the VictorLink node application with the following command.

java -jar node/build/libs/node-v1.0.jar -k key.store

Specific configuration items can also be specified via the command line, e.g.

java -jar node/build/libs/node-v1.0.jar --server.port=8081 --spring.profiles.active=dev --key key.store

Use the following command to determine if the VictorLink node is operational.

tail -f logs/vision.log

Warning

The node account must have enough VS tokens for contract calls. This can be requested through the test network tap address.

Adding a Job to a Node

The job of a node represents the data service supported by the node, and the job ID is uniquely identified by a 32-byte number. To the end user, the (Oracle address, job ID) uniquely identifies the data services provided by a VictorLink node. Each VictorLink node can provide multiple sets of data services.
Once the VictorLink node is up and running, jobs can be added to the node via the HTTP API:
Example: (modify the address parameter in the following code to be the address of the Oracle contract deployed in the above step)

curl --location --request POST 'http://localhost:8080/job/specs' \
  --header 'Content-Type: application/json' \
    --data-raw '{
    "initiators": [
        {
        "type": "runlog",
        "params": {
            "address": ""
        }
        }
    ],
    "tasks": [
        {
        "type": "httpget",
        "params": {
            "get": "https://xxxxxxxxx",
            "path": "last"
        }
        },
        {
        "type": "multiply",
        "params": {
            "times": 1000000
        }
        },
        {
        "type": "visiontx"
        }
    ]
    }'

Query Node Job

curl --location --request GET 'http://localhost:8080/job/specs'

Authorization for Node Accounts

Node accounts need to be authorized to submit data to the Oracle contract, otherwise an error "Not an authorized node to fulfill requests" will be reported.
You need to add the node account to the whitelist by making the following contract call using the owner of the Oracle contract:

// setFulfillmentPermission(address,bool) [7fcd56db]
function setFulfillmentPermission(address _node, bool _allowed)

Where _node is the node account address, _allowed is true for authorization, false for revocation.
Example calls such as setFulfillmentPermission(VGQVLckg1gDZS5wUwPTrPgRG4U8MKC4jcP, true).

Apply to become an official certified VictorLink node

Ondoing.....


Did this page help you?