Packages
signet
1.0.0-alpha7
1.6.1
1.6.0
1.5.0
1.4.2
1.4.1
1.4.0
1.3.12
1.3.11
1.3.10
1.3.9
1.3.8
1.3.7
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.9
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.2
1.1.1
1.1.0
1.0.0-echo8
1.0.0-echo7
1.0.0-echo6
1.0.0-echo5
1.0.0-echo4
1.0.0-echo3
1.0.0-echo2
1.0.0-echo1
1.0.0-delta8
1.0.0-delta7
1.0.0-delta6
1.0.0-delta5
1.0.0-delta4
1.0.0-delta3
1.0.0-delta2
1.0.0-delta1
1.0.0-charlie9
1.0.0-charlie8
1.0.0-charlie7
1.0.0-charlie6
1.0.0-charlie5
1.0.0-charlie4
1.0.0-charlie3
1.0.0-charlie2
1.0.0-charlie1
1.0.0-beta9
1.0.0-beta8
1.0.0-beta7
1.0.0-beta6
1.0.0-beta5
1.0.0-beta4
1.0.0-beta3
1.0.0-beta2
1.0.0-beta1
1.0.0-alpha9
1.0.0-alpha8
1.0.0-alpha7
1.0.0-alpha6
1.0.0-alpha5
1.0.0-alpha4
1.0.0-alpha3
1.0.0-alpha2
1.0.0-alpha10
1.0.0-alpha1
0.2.0-alpha6
0.2.0-alpha5
0.2.0-alpha4
0.2.0-alpha1
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.1.0-rc7
0.1.0-rc6
0.1.0-rc5
0.1.0-rc4
0.1.0-rc3
0.1.0-rc2
0.1.0-rc1
0.1.0-rc0
Lightweight Ethereum and Solana RPC client for Elixir
Current section
Files
Jump to
Current section
Files
lib/signet.ex
defmodule Signet do
@moduledoc """
Signet is a library for interacting with private keys, signatures, and Etheruem.
"""
@type address :: <<_::160>>
@type signature :: <<_::520>>
@type bytes32 :: <<_::256>>
@type contract :: address() | atom()
@doc ~S"""
Returns a contract address, that may have been set in configuration.
## Examples
iex> Signet.get_contract_address(<<1::160>>)
<<1::160>>
iex> Signet.get_contract_address("0x0000000000000000000000000000000000000001")
<<1::160>>
iex> Application.put_env(:signet, :contracts, [test: "0x0000000000000000000000000000000000000001"])
iex> Signet.get_contract_address(:test)
<<1::160>>
iex> Application.put_env(:signet, :contracts, [test: "0x0000000000000000000000000000000000000001"])
iex> Signet.get_contract_address(:test_00)
** (KeyError) key :test_00 not found in: [test: "0x0000000000000000000000000000000000000001"]
"""
def get_contract_address(address) when is_binary(address),
do: Signet.Util.decode_hex_input!(address)
def get_contract_address(contract) when is_atom(contract) do
Application.get_env(:signet, :contracts, [])
|> Keyword.fetch!(contract)
|> Signet.Util.decode_hex_input!()
end
end