📝 Whitelisting with Remix
What is Remix?
Remix is an open source, online, integrated development environment (IDE) for developing, debugging and deploying smart contracts.
What is this guide for?
To be able to read data from a deployed Beacon, address of the reader (EOA or another contract) must be whitelisted. This guide will walk you through whitelisting a Metamask account on the Mumbai Testnet and reading the data from a Beacon using RemixIDE.
Step 1
- Go to Remix and clone the airnode-protocol-v1 repository.
https://github.com/api3dao/airnode-protocol-v1.git
- Click on
Clone Git Repository
button and enter the repository https link to the popped-up text box.
- Once the repository is cloned, the Remix file explorer should look like below.
Step 2
Now, we will connect the Metamask account to Remix, and then connect to
DapiServer.sol
to try to read the data from the Beacon.Compile the
/airnode-protocol-v1/contracts/dapis/DapiServer.sol
contract from theSolidity compiler
section.
- Go to the
Deploy & run transactions
section from sidebar. SelectInjected Provider - Metamask
fromENVIRONMENT
, selectDapiServer
fromCONTRACT
and enterDapiServer.sol
's address on the Mumbai Testnet next toAt Address
button as in the below image and click theAt Address
button.
DapiServer.sol
's address on the Mumbai Testnet:
0x71Da7A936fCaEd1Ee364Df106B12deF6D1Bf1f14
- After clicking the
At Address
button, the contract should be seen in theDeployed Contracts
section. - Click on the contract and find the
readDataFeedWithId
function. - Enter the
dataFeedId
parameter and click thecall
button as in the below image.
dataFeedId
:
0x0dc124b07cc935112d87b49c806c5c880659dd7a2ef75b4ea04460cf224ea2c0
- Since we didn't whitelist our account yet, we should see the following error message in the Remix console, which indicates that the sender (our account) cannot read the data.
call to DapiServer.readDataFeedWithId errored: Internal JSON-RPC error.
{
"code": 3,
"message": "execution reverted: Sender cannot read",
"data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001253656e6465722063616e6e6f7420726561640000000000000000000000000000"
}
Step 3
- Now clone utility-contracts repository.
https://github.com/api3dao/utility-contracts.git
- Compile
/utility-contracts/SelfServeDapiServerWhitelister/contracts/SelfServeDapiServerWhitelister.sol
- Go to
Deploy & run transactions
. SelectInjected Provider - Metamask
fromENVIRONMENT
, selectSelfServeDapiServerWhitelister.sol
fromCONTRACT
and enterSelfServeDapiServerWhitelister.sol
's address on Mumbai Testnet next toAt Address
button as in the below image and click theAt Address
button.
SelfServeDapiServerWhitelister.sol
's address on Mumbai Testnet:
0x78D95f27B068F36Bd4c3f29e424D7072D149DDF3
- After clicking the
At Address
button, theSelfServeDapiServerWhitelister
contract should be seen in theDeployed Contracts
section. - Click on the contract and find the
allowToReadDataFeedWithIdFor30Days
function. - Enter
dataFeedId
andreader
parameters and click thetransact
button and confirm transaction from Metamask.reader
is your Metamask address.
- After the transaction is confirmed, we should see below message on the Remix Console.
Step 4
- Now go back to the
airnode-protocol-v1
workspace from Remix.
Again, compile
DapiServer.sol
, select the properENVIRONMENT
,CONTRACT
and enterDapiServer.sol
's address on Mumbai Testnet next toAt Address
button in theDeploy & run transaction
section and click theAt Address
button and click deployed contract.Find the
readDataFeedWithId
function, enter thedataFeedId
parameter and clickcall
.Since we whitelisted our account, we should see return values in section where we enter parameters as in the below image.
Each value that is written to chain is multiplied by 1018 in this example. Since floating numbers do not exist in Solidity, this solution is required to handle decimal places.