TRS
Deploy Contracts and ts Call
Tools
Git: Code Management Tool
Node: Development Tool
Rust: Development Language Environment
Cargo: Contract Development Environment
Solana: Contract Development Environment
Visual Studio Code: Development Tool
Clone TRS Project
Go and visit our github repo via https: //github.com/cryptoera2022/TRS_contract, and download the project code.
Use Visual Studio Code to open the project root directory, and then run and edit the project.
Installation Environment Dependency
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.
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
View the current Solana network: solana config get Solana network: mainnet, devnet, testnet Modify network: solana config set --url testnet
Packaging and Deployment
Go to the project clients directory and install the Node dependency: NPM install.
Use command to package the Oracle contract project: npm run build:oracle
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
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.
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.
Run the ts command: Under the client directory: npm run start: oracle View the output information in the terminal.
Last updated