View Source Aptos SDK for Elixir
A toolkit for working with Aptos in Elixir.
This library is still a work-in-progress, but is already quite usable at this state.
Bug reports and pull requests are hugely welcomed.
installation
Installation
The package can be installed by adding aptos
to your list of dependencies in mix.exs
:
def deps do
[
{:aptos, "~> 0.2.4"},
{:bcs, "~> 0.1.1", hex: :ex_bcs}
]
end
You need to provide a network configuration, for example:
# Configures Aptos
config :aptos, :network,
node_url: "https://fullnode.devnet.aptoslabs.com/v1",
faucet_url: "https://faucet.devnet.aptoslabs.com",
chain_id: 53
API clients are using Tesla
with Finch
as the HTTP client, therefore you also need to configure Tesla
, for example:
# Configures Tesla
config :tesla, :adapter, {
Tesla.Adapter.Finch,
name: Aptos.Finch, receive_timeout: 15_000
}
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/aptos.
usage
Usage
API endpoints are implemented in Aptos.RestClient
and Aptos.BcsClient
.
A faucet client is also provided in Aptos.FaucetClient
.
When working with smart contracts, we'd like to be able to read and write data from the blockchain network.
The Aptos.Contract.Coin
module may serve as a good example for making use of this library when working with your own smart contracts.
To submit a transaction, first generate a {payload, payload_layout}
tuple, like in Aptos.Contract.Coin.transfer/3
, then submit it to the network with Aptos.Tx.submit/3
.