Once you have an Ethereum gateway — meaning that you create a new gateway with a target of Ethereum — you can interact with different Ethereum networks by specifying the correct JSON blob for your query.
Read from the network
The Cloudflare Ethereum Gateway allows HTTP requests where the body of the request is set to be the JSON body of the request you would like to make. For example, if you would like to read the block that is at number 0x2244, then your JSON blob takes the form:
Each blob use a valid method parameter. The params array here contains the block number that we would like to locate and a boolean expressing whether each individual transaction in the block should be shown in their entirety (true) or as stubs (false).
You can also write the same query using the JS Fetch API:
The response in both cases will be a JSON blob of the form:
Write to the network
Currently, the Ethereum Gateway allows you to write to the network using the eth_sendRawTransaction RPC method. This creates a new message call transaction or a contract creation for signed transactions. The transactions are signed using a secret key corresponding to your own Ethereum wallet ↗.
Once you have a wallet set up and a method of signing your own transactions, you can write that transaction to the Ethereum network via the Cloudflare Ethereum Gateway. Signed transactions use hexadecimal strings of the form:
Then you can use your custom Gateway to send the transaction to the network with a cURL command:
You could also use a JS Fetch API request:
(The actual command above will not work — you need to provide your own signed transaction.)
Was this helpful?
What did you like?
What went wrong?
Thank you for helping improve Cloudflare's documentation!