Usage
Starting the Erlang Process
-
Navigate to the project directory and install deps :
cd examples/erlang-bridge/src
yarn install -
Replace RPC_URL in
sdk.js
with the actual RPC URL and set thechain
parameter to which chain you want to connect:const rpcProvider = createPublicClient({
chain: mainnet,
transport: http('RPC_URL'),
}); -
Start the Erlang shell:
rebar3 get-deps && rebar3 compile
erlc main.erl
erl -pa _build/default/lib/*/ebin
-
In the Erlang shell, compile the
main
module:c(main).
-
Start the Node.js process from Erlang and get the port:
{ok, Port} = main:start().
-
Define the parameters and call the
get_rewards_from_chain
function:Params = [
{<<"address">>, <<"0x">>},
{<<"stepBlock">>, 10000},
{<<"back">>, {<<"days">>, 1}}
].
Result = main:get_rewards_from_chain(Port, Params).- address: Ethereum address for which to retrieve rewards.
- stepBlock: Max blocks in 1 query - depend on the RPC capabilities and pricing plans
- back.days: Number of days to step back.