Skip to main content

📝 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

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 the Solidity compiler section.

  • Go to the Deploy & run transactions section from sidebar. Select Injected Provider - Metamask from ENVIRONMENT, select DapiServer from CONTRACT and enter DapiServer.sol's address on the Mumbai Testnet next to At Address button as in the below image and click the At Address button.

DapiServer.sol's address on the Mumbai Testnet:

0x71Da7A936fCaEd1Ee364Df106B12deF6D1Bf1f14

  • After clicking the At Address button, the contract should be seen in the Deployed Contracts section.
  • Click on the contract and find the readDataFeedWithId function.
  • Enter the dataFeedId parameter and click the call 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

https://github.com/api3dao/utility-contracts.git
  • Compile /utility-contracts/SelfServeDapiServerWhitelister/contracts/SelfServeDapiServerWhitelister.sol
  • Go to Deploy & run transactions. Select Injected Provider - Metamask from ENVIRONMENT, select SelfServeDapiServerWhitelister.sol from CONTRACT and enter SelfServeDapiServerWhitelister.sol's address on Mumbai Testnet next to At Address button as in the below image and click the At Address button.

SelfServeDapiServerWhitelister.sol's address on Mumbai Testnet:

0x78D95f27B068F36Bd4c3f29e424D7072D149DDF3

  • After clicking the At Address button, the SelfServeDapiServerWhitelister contract should be seen in the Deployed Contracts section.
  • Click on the contract and find the allowToReadDataFeedWithIdFor30Days function.
  • Enter dataFeedId and reader parameters and click the transact 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 proper ENVIRONMENT, CONTRACT and enter DapiServer.sol's address on Mumbai Testnet next to At Address button in the Deploy & run transaction section and click the At Address button and click deployed contract.

  • Find the readDataFeedWithId function, enter the dataFeedId parameter and click call.

  • Since we whitelisted our account, we should see return values in section where we enter parameters as in the below image.

info

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.

Where do I find all those addresses?