Cardanoex.Transaction (cardanoex v0.6.3)
The Transaction module lets you work with transactions for a wallet.
Link to this section Summary
Functions
Create and send transaction from the wallet.
Estimate fee for the transaction.
The estimate is made by assembling multiple transactions and analyzing the distribution of their fees.
The estimated_max
is the highest fee observed, and the estimated_min
is the fee which is lower than at least 90% of the fees observed.
Get transaction by id.
Lists all incoming and outgoing wallet's transactions.
Link to this section Types
amount()
@type amount() :: %{quantity: non_neg_integer(), unit: String.t()}
asset()
@type asset() :: %{ policy_id: String.t(), asset_name: String.t(), quantity: non_neg_integer() }
collateral()
@type collateral() :: %{ address: String.t(), amount: amount(), id: String.t(), index: non_neg_integer() }
create_transaction()
fee_estimation()
input()
@type input() :: %{ address: String.t(), amount: amount(), assets: [asset()], id: String.t(), index: non_neg_integer() }
output()
payment()
@type payment() :: %{ address: String.t(), amount: non_neg_integer(), assets: [asset()] | nil }
transaction()
@type transaction() :: %{ amount: amount(), collateral: [collateral()], deposit: amount(), depth: %{quantity: non_neg_integer(), unit: String.t()}, direction: String.t(), expires_at: %{ absolute_slot_number: non_neg_integer(), epoch_number: non_neg_integer(), slot_number: non_neg_integer(), time: String.t() }, fee: amount(), id: String.t(), inputs: [input()], inserted_at: %{ absolute_slot_number: non_neg_integer(), epoch_number: non_neg_integer(), height: %{quantity: non_neg_integer(), unit: String.t()}, slot_number: non_neg_integer(), time: String.t() }, metadata: map() | nil, mint: list(), outputs: [output()], pending_since: %{ absolute_slot_number: non_neg_integer(), epoch_number: non_neg_integer(), height: %{quantity: non_neg_integer(), unit: String.t()}, slot_number: non_neg_integer(), time: String.t() }, status: String.t(), withdrawals: [withdrawal()], script_validity: String.t() | nil }
withdrawal()
Link to this section Functions
create(wallet_id, transaction)
@spec create(String.t(), create_transaction()) :: {:error, String.t()} | {:ok, transaction()}
Create and send transaction from the wallet.
options
Options
wallet_id
- hex based string. 40 characterstransaction
- A map with the following structure:
%{
payments: [
%{
address: "addr_test1qruzy7l5...nq04es9elzy7",
amount: %{quantity: 42_000_000, unit: "lovelace"}
}
]
}
# With asset:
%{
payments: [
%{
address:"addr_test1qruzy7l5...nq04es9elzy7",
amount: %{quantity: 1_407_406, unit: "lovelace"},
assets: [
%{
policy_id: "6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7",
asset_name: "",
quantity: 0
}
]
}
]
}
# With metadata:
%{
payments: [
%{
address: "addr_test1qruzy7l5...nq04es9elzy7",
amount: %{quantity: 1_407_406, unit: "lovelace"}
}
],
metadata: %{"0" => %{"string" => "cardano"}, "1" => %{"int" => 14}}
}
estimate_fee(wallet_id, transaction)
@spec estimate_fee(String.t(), create_transaction()) :: {:error, String.t()} | {:ok, fee_estimation()}
Estimate fee for the transaction.
The estimate is made by assembling multiple transactions and analyzing the distribution of their fees.
The estimated_max
is the highest fee observed, and the estimated_min
is the fee which is lower than at least 90% of the fees observed.
options
Options
wallet_id
- hex based string. 40 characterstransaction
- A map with the following structure:
%{
payments: [
%{
address: "addr_test1qruzy7l5...nq04es9elzy7",
amount: %{quantity: 42_000_000, unit: "lovelace"}
}
]
}
# With asset:
%{
payments: [
%{
address:"addr_test1qruzy7l5...nq04es9elzy7",
amount: %{quantity: 1_407_406, unit: "lovelace"},
assets: [
%{
policy_id: "6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7",
asset_name: "",
quantity: 0
}
]
}
]
}
# With metadata:
%{
payments: [
%{
address: "addr_test1qruzy7l5...nq04es9elzy7",
amount: %{quantity: 1_407_406, unit: "lovelace"}
}
],
metadata: %{"0" => %{"string" => "cardano"}, "1" => %{"int" => 14}}
}
get(wallet_id, transaction_id)
@spec get(String.t(), String.t()) :: {:error, String.t()} | {:ok, transaction()}
Get transaction by id.
options
Options
transaction_id
- Transaction ID
list(wallet_id, options \\ [])
@spec list(String.t(), start: String.t(), stop: String.t(), order: atom(), min_withdrawal: non_neg_integer() ) :: {:error, String.t()} | {:ok, [transaction()]}
Lists all incoming and outgoing wallet's transactions.
options
Options
start
- An optional start time in ISO 8601 date-and-time format. Basic and extended formats are both accepted. Times can be local (with a timezone offset) or UTC. If both a start time and an end time are specified, then the start time must not be later than the end time. Example:2008-08-08T08:08:08Z
stop
- An optional end time in ISO 8601 date-and-time format. Basic and extended formats are both accepted. Times can be local (with a timezone offset) or UTC. If both a start time and an end time are specified, then the start time must not be later than the end time.order
- Can be set to:descending
or:ascending
. Defaults to:descending
min_withdrawal
- Returns only transactions that have at least one withdrawal above the given amount. This is particularly useful when set to1
in order to list the withdrawal history of a wallet.