'Regarding Oracle Node as a NEAR Protocol Contract implemented in Rust

Recently, I have been executing the implementation of this repository:

https://github.com/smartcontractkit/near-protocol-contracts

So, everything is working fine in this...


But what I want to ask in this is:

When I executed the request command:

near call oracle.$NEAR_ACCT request '{"payment": "10", "spec_id": "dW5pcXVlIHNwZWMgaWQ=", "callback_address": "client.'$NEAR_ACCT'", "callback_method": "token_price_callback", "nonce": "11", "data_version": "1", "data": "eyJnZXQiOiJodHRwczovL21pbi1hcGkuY3J5cHRvY29tcGFyZS5jb20vZGF0YS9wcmljZT9mc3ltPUVUSCZ0c3ltcz1VU0QiLCJwYXRoIjoiVVNEIiwidGltZXMiOjEwMH0="}' --accountId client.$NEAR_ACCT --gas 300000000000000

The resultant transaction was:

https://explorer.testnet.near.org/transactions/Gr4ddg77Hj1KN2EB3W7vErc6aaDq8sNPfo6KnQWkN9rm

And then, I executed the fulfill_request command:

near call oracle.$NEAR_ACCT fulfill_request '{"account": "client.'$NEAR_ACCT'", "nonce": "11", "data": "Nzg2"}' --accountId oracle-node.$NEAR_ACCT --gas 300000000000000

Then, the resultant transaction was:

https://explorer.testnet.near.org/transactions/39XZF81s9vGDzbUkobQZJufGxAX7wNrPT336S8TEnk29


NOTE:

As we can see in the first command that is request, the data parameter that is passed is:

eyJnZXQiOiJodHRwczovL21pbi1hcGkuY3J5cHRvY29tcGFyZS5jb20vZGF0YS9wcmljZT9mc3ltPUVUSCZ0c3ltcz1VU0QiLCJwYXRoIjoiVVNEIiwidGltZXMiOjEwMH0=

When we base64 decode that, then it comes out to be as:

{"get":"https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD","path":"USD","times":100}

request-data

Similarly, in the second command that is fulfill_request, I passed the data parameter as:

Nzg2

When we base64 decode that, it comes out to be as:

786

fulfill_request-data

And, that is also the result of the second transaction that you can see by scrolling to the midway of https://explorer.testnet.near.org/transactions/39XZF81s9vGDzbUkobQZJufGxAX7wNrPT336S8TEnk29.

We can see the result as:

Client contract received price: "786"


So, basically what I want is:

To get the response of https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD as the result of fulfill_request command, instead of hard-coded 786.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source