midgard command-line tool does this for you.
Send a transaction with the CLI
1
Build the CLI
From a checkout of Commands below use
sundial-monorepo:node dist/bin.js. By default they connect to http://localhost:3000. Pass --endpoint https://rpc.testnet.sundialprotocol.com to use the public testnet node.2
Create a wallet
addr_test1… address and saves the wallet locally under the name you gave it.3
Fund it
4
Send
5
Confirm it was accepted
Build transactions in your own code
The L2 uses a Cardano-style transaction format, so libraries such as Lucid Evolution can build transactions. The difference is the provider:- Read spendable outputs from
GET /utxoson the L2 node. - Build and sign the transaction. The fee follows the node’s formula: 44 lovelace per byte plus 155,381.
- Submit the hex-encoded transaction to
POST /submit. - Poll
GET /tx?tx_hash=…until the node returns it.
Deposit from L1
A deposit is an L1 transaction that sends tokens to the L2’s deposit contract and names the L2 address to credit. The block whose time interval covers the deposit’s inclusion time must include it, and your funds then appear on L2. Build it with the SDK: see Constructing a deposit.Withdraw to L1
A withdrawal is an L1 transaction that posts a withdrawal order: which L2 output to withdraw, and which L1 address to pay.- The order is included in an L2 block, which removes the output from the L2 ledger.
- The block waits out the maturity period and is merged.
- The order is paid out from the reserve to your L1 address.