TRS

Deploy Contracts and ts Call

Tools

  1. Git: Code Management Tool

  2. Node: Development Tool

  3. Rust: Development Language Environment

  4. Cargo: Contract Development Environment

  5. Solana: Contract Development Environment

  6. Visual Studio Code: Development Tool

Clone TRS Project

  1. Go and visit our github repo via https: //github.com/cryptoera2022/TRS_contract, and download the project code.

  2. Use Visual Studio Code to open the project root directory, and then run and edit the project.

Installation Environment Dependency

  1. Basically you need to install cargo environment and solana environment. Suppose you are using Windows ysstem you need to install wsl and ubuntu subsystem at first. For more details you can refer to the environment installation documentation.

  2. You can use the solana command to generate local accounts and private key files, or you can import accounts from other places. Generate the account command: solana-keygen new --outfile id.json

  3. View the current Solana network: solana config get Solana network: mainnet, devnet, testnet Modify network: solana config set --url testnet

Packaging and Deployment

  1. Go to the project clients directory and install the Node dependency: NPM install.

  2. Use command to package the Oracle contract project: npm run build:oracle

  3. Use command to publish Oracle contract project: npm run deploy:oracle The project will be deployed on the current Solana network by default. Therefore, please ensure that the default local account has sufficient SOL balance on the current network for completing project deployment and paying the fees for contract invocation. For now the program supports only devnet and testnet environments.

Run Contract

  1. Copy the local deployment contract account id.json to clients/dist/ and replace or modify it with oracle_owner.json account, which is used to generate the address derived from the historical price account.

  2. Ts calls oracle contract methods: a: establishConnection -- Set up a list of supported currencies based on the link network. b: nitFormAccount -- Read oracle_owner.json account. c: checkProgram -- Check whether the Oracle contract program has been deployed. d: nitOrUpdateTokenDayAccount -- Every initialization or update of the price account information of the token list. e: getOracleHistoryData -- Query the price account information of the token list on a given day. Methods A, B, and C are operating conditions that need to be turned on all the time. Whether D or E need to be turned on or not according to requirements.

  3. Run the ts command: Under the client directory: npm run start: oracle View the output information in the terminal.

Last updated