JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
Mini Blinkathon - San Francisco ☀️
Mini Blinkathon - San Francisco ☀️
What are Solana Actions?
What are Blockchain Links? (Blinks)
Examples of Blinks
More
Share
Explore
What are Solana Actions?
Implementing Solana Actions
Basic Implementation
Define Action URL
:
javascript
Copy code
const actionUrl = 'https://actions.example.com/transaction';
Create Action Endpoint
:
Define a GET route to provide human-readable information.
Define a POST route to handle transaction construction and signing.
const
express
=
require
(
'express'
)
;
const
app
=
express
(
)
;
app
.
get
(
'/transaction'
,
(
req
,
res
)
=>
{
res
.
json
(
{
name
:
'Transaction Example'
,
description
:
'An example transaction action'
,
}
)
;
}
)
;
app
.
post
(
'/transaction'
,
(
req
,
res
)
=>
{
// Logic to create and return a transaction for signing
}
)
;
app
.
listen
(
3000
,
(
)
=>
console
.
log
(
'Server running on port 3000'
)
)
;
Integrate with Dialect
:
const { Dialect, SolanaDialectWalletAdapter } = require('@dialectlabs/sdk');
const dialect = new Dialect({
wallet: new SolanaDialectWalletAdapter({ connection }),
});
dialect.createNotification({
title: 'Action Required',
message: 'Sign the transaction',
action: {
type: 'link',
url: actionUrl,
},
});
console.log('Notification created');
Advanced Implementation
Multi-Actions
: Group multiple actions in a single GET call.
Complex Transactions
: Handle more sophisticated transaction scenarios by using advanced routing and transaction construction logic.
javascript
Copy code
app.post('/complex-transaction', (req, res) => {
const { actionType } = req.body;
if (actionType === 'swap') {
// Logic for swap action
} else if (actionType === 'stake') {
// Logic for stake action
}
res.send('Transaction created');
});
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.