Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Jan 29, 2025
1 parent 606b96b commit 8b5f650
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,60 @@ const tx = await lucid

See [more examples](./tests/data.test.ts)

### Instructions

Lucid transactions can be converted into instructions, which are JSON, making them highly portable.

```js
const instructions = await lucid.newTx()
.delegateTo("{{own}}", "pool...")
.payTo("addr_test1...", { lovelace: 1000000n })
.toInstructions();
```

The above transaction can be converted into the following object:

```js
[
{
"type": "DelegateTo",
"delegation": {
"rewardAddress": "stake...",
"poolId": "pool..."
},
"redeemer": undefined
},
{
"type": "PayTo",
"address": "addr_test1...",
"assets": { "lovelace": 1000000n }
}
]
```

Consume the instructions in Lucid:

```js
const tx = await lucid.fromInstructions([
{
"type": "DelegateTo",
"delegation": {
"rewardAddress": "stake...",
"poolId": "pool...",
},
"redeemer": undefined,
},
{
"type": "PayTo",
"address": "addr_test1...",
"assets": { "lovelace": 1000000n },
},
]);
```

You can avoid address resolution if you use `.toPartialInstructions()` instead of `.toInstructions()`.\
Then Lucid will resolve `{{own}}` fields with the addresses of the selected wallet.

### Test

```
Expand Down

0 comments on commit 8b5f650

Please sign in to comment.