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.jswith the actual RPC URL and set thechainparameter to which chain you want to connect:const rpcProvider = createPublicClient({
chain: mainnet,
transport: http('RPC_URL'),
}); -
Start the Erlang shell:
rebar3 get-deps && rebar3 compileerlc main.erlerl -pa _build/default/lib/*/ebin -
In the Erlang shell, compile the
mainmodule: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_chainfunction: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.