Tradehub.Tx.build
You're seeing just the function
build
, go back to Tradehub.Tx module for more information.
Build a package for broadcasting arcoss the chain, the package includes the given messages, and signed by using the private key of the given tradehub Wallet
Packaging messages consists steps as below:
- Given raw messages that constist of the message
type
and anobject
containing the message params. - Construct signing messages
- Construct the digest by marshalling the
signing message
into a JSON format, and applying the hash algorithm SHA256 - Sign the digest with the private key
- Combine the messages with its signatur, set fee, and memo if any.
- Complete Tx, mode:
block
to wait for the txn to be accepted into the block.
Examples
iex> wallet = Tradehub.Wallet.create_wallet()
iex> message = %{
...> type: "order/CreateOrder",
...> value: %{
...> Market: "swth_eth",
...> Side: "sell",
...> Quantity: "200",
...> Price: "1.01",
...> Originator: "swth1z2jz4uhz8zgt4lq9mq5slz3ukyp3grhl7nsr4x"
...> }
...> }
iex> Tradehub.Tx.build(message, wallet)