Creating an Oracle Request
In order for the DSP to know what information it is that you want to receive, there is a format to creating an oracle request.
Each of the following oracle request types comes equipped with its own syntax that gets encoded with Buffer.from("<URI HERE>", 'utf8'). The following guide will explain the syntax to generate your URI. Each URI should be passed through the buffer as plaintext is not accepted.
NodeJS example:
1
const body = Buffer.from('{"block_num_or_id":"36568000"}').toString('base64')
2
const res = await testcontract.testrnd({
3
uri: Buffer.from(`https+post+json://timestamp/${body}/mainnet.eosn.io:443/v1/chain/get_block`, 'utf8')
4
}, {
5
authorization: `${code}@active`,
6
broadcast: true,
7
sign: true
8
});
Copied!
Smart contract example (from here):
1
[[eosio::action]] void testrnd(std::vector<char> uri) {
2
getURI(uri, [&]( auto& results ) {
3
return results[0].result;
4
});
5
}
Copied!
Explore the different APIs in the following categories.
Last modified 6mo ago
Copy link