Create multi-step experiences with blinks using action chaining
app.get('SOL-BONK', async (c) => { ... }
(link) returns an an input field (a linked parameterized action) for the user to specify the amount to swap. This is no different than a non-chained actions response.
On submit, a POST call is made to app.post('SOL-BONK/:amount', async (c) => { ... }
(link). This response includes both the transaction data as expected, but now also the links
attribute with a next
attribute in it. This next
attribute powers action chaining.
response.links.next.href
URL is the relative path to the next action, and type: 'post'
indicating that chaining is done through a POST request to the specified href. The alternative chaining method, type: 'inline'
, will be explained in the next section.
app.post(/BONK-SOL', async (c) => { ... }
(link), which returns metadata to render the second action in the chain.
app.post('/BONK-SOL/:amount', async (c) => { ... }
(link) which then returns the transaction to sign and submit to the blockchain.
See the full code here, or browse other action chaining examples here.
links.next.href
string for the URL to call in the next step that would return an Action object, that Action object is returned directly in links.next.action
.