Using Acurast to provide price feed data for BTC/USDT

Introduction

Acurast is a decentralized computing protocol that does the same as centralized computing service providers. These service providers include AWS, Google, and Azure.

By the end of this tutorial, you will have created a job on Acurast and gotten the price feed for the contract you deployed.

Prerequisites

To follow through with this tutorial, you need to have and know these:

Smart Contract

This section will use solidity to create the smart contract we want Acurast to communicate.

Open your Remix IDE

Head over to Remix, open it, and create a solidity-based file called getBTCPrice.sol.

Run your Solidity Code

Inside the solidity file you have created, copy and paste this code below:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract PriceFeed {
    uint public latestPrice;
    uint public lastUpdated;
    /**
     * Receive price feed (BTC price) from an Acurast job.
     */
    function updatePrice(uint _price) external {
    // Update price
        latestPrice = _price;
        lastUpdated = block.timestamp;
    }
    /**
     * Get the latest BTC/USD price.
     */
    function getLatestPrice() public view returns (uint) {
        require(block.timestamp - lastUpdated < 1 hours, "Price is outdated");
        return latestPrice;
    }
}

Open up your Acurast Console.

When you open your console, you should have this dashboard:

dashboard

Click on "Create Jobs." and you should have this:

Choose the Ethereum chain:

gettingETH

Editing your Acurast Job Script

Here, you will edit the provided job script for price feed to point to BTC/USDT for your smart contract.

After you have, scroll down, and you should see a javascript script. You could edit some elements in the price feed to fit into the purpose of the solidity code you have above.

On line 1, replace the variable with:

 const destination = "0x7ef887d376CC6F7FCE716e469F351F6FCABB1CaE";

And it would help if you also replaced the AAVEBUSD API with that of BTC/USDT. Now, go ahead and add other variables to your job creation. Specify processor details:

You should specify the execution schedule, job environment variables, and additional parameters.

execution

After you are done setting the parameters. Choose an amount you are willing to pay and create the job.

Conclusion

According to Acurast documentation, Ethereum works on level 1.This means you'd have to send some ETH tokens to the processor's address to handle the job for you.

Now that you have created a job or deployed. Congratulations, do well to explore more of Acurast's offerings: https://acurast.com/