View Source Icon.RPC.Identity (ICON 2.0 SDK v0.2.3)

This module defines a struct with the basic identity information to query and transact with the ICON 2.0 JSON API.

There are two types of identities:

  • With wallet.
  • Without wallet.

For most methods, we'll only need an identity without a wallet. However, for transactions is necessary we add a wallet to our identity.

Identities have the following fields:

  • network_id - Which is either the name (network_name/0) or the network ID number. Defaults to :mainnet (it's the same as 1).
  • node - The URL to the node we want to use. It has default node URL per network_id for convinience, but they can be overriden.
  • debug - Whether the debug endpoint should be used or not. Defaults to false.
  • key - It's a Curvy.Signature.t(), though it's not visible when inspecting the struct. Instead the field shown would be an incomplete private_key.
  • address - EOA address derived from the private_key.

e.g. the following creates an identity for interacting with Sejong testnet:

iex> Icon.RPC.Identity.new(network_id: :sejong, private_key: "8ad9...")
#Identity<[
  node: "https://sejong.net.solidwallet.io",
  network_id: "0x53 (Sejong)",
  debug: false,
  address: "hxfd7e4560ba363f5aabd32caac7317feeee70ea57",
  private_key: "8ad9..."
]>

networks

Networks

Though in theory any ICON network can be used, this API only supports ICON 2.0 networks by name.

mainnet

Mainnet

This is ICON 2.0 network and the default option when creating an identity.

iex> Icon.RPC.Identity.new()
#Identity<[
  node: "https://ctz.solidwallet.io",
  network_id: "0x1 (Mainnet)",
  debug: false
]>

sejong

Sejong

This test network is for testing applications without going through an audit and therefore may be unstable. It is equivalent to Yeouido network in ICON 1.0.

iex> Icon.RPC.Identity.new(network_id: :sejong)
#Identity<[
  node: "https://sejong.net.solidwallet.io",
  network_id: "0x53 (Sejong)",
  debug: false
]>

berlin

Berlin

This test network offers the latest features and may be unstable. Resets will happen frequently without notice.

iex> Icon.RPC.Identity.new(network_id: :berlin)
#Identity<[
  node: "https://berlin.net.solidwallet.io",
  network_id: "0x7 (Berlin)",
  debug: false
]>

lisbon

Lisbon

This is the long term support test network. It should be use to test applications in an environment close to mainnet. This is where you'll often see applications beta versions. Though resets can happen, they'll be avoided as much as possible. It is equivalent to Euljiro network in ICON 1.0.

iex> Icon.RPC.Identity.new(network_id: :lisbon)
#Identity<[
  node: "https://lisbon.net.solidwallet.io",
  network_id: "0x2 (Lisbon)",
  debug: false
]>

Link to this section Summary

Types

Network name.

Initialization option.

Initialization options.

t()

Identity.

Functions

Connection struct.

Whether the identity can sign or not.

Whether the identity has an EOA address or not.

Creates a new connection given some options.

Link to this section Types

@type network_name() :: :mainnet | :sejong | :berlin | :lisbon

Network name.

@type option() ::
  {:node, binary()}
  | {:network_id, pos_integer()}
  | {:network_id, Icon.Schema.Types.BinaryData.t()}
  | {:network_id, network_name()}
  | {:private_key, :generate | binary()}

Initialization option.

@type options() :: [option()]

Initialization options.

@type t() :: %Icon.RPC.Identity{
  address: nil | Icon.Schema.Types.EOA.t(),
  debug: boolean(),
  key: nil | Curvy.Key.t(),
  network_id: pos_integer(),
  node: binary()
}

Identity.

Link to this section Functions

Link to this function

%Icon.RPC.Identity{}

View Source (struct)

Connection struct.

Link to this macro

can_sign(identity)

View Source (macro)
@spec can_sign(t()) :: Macro.t()

Whether the identity can sign or not.

Link to this macro

has_address(identity)

View Source (macro)
@spec has_address(t()) :: Macro.t()

Whether the identity has an EOA address or not.

@spec new(options()) :: t()

Creates a new connection given some options.

Options:

  • node - ICON 2.0 JSON API URL.
  • network_id - Either the name of the network or, its ID in hex string or integer.
  • debug - Whether the requests should be done in the debug endpoint or not.
  • private_key - Wallet private key as hex string.