Solana Foundation has introduced Solana Actions and Solana Blinks, two innovative features designed to make blockchain transactions more seamless and intuitive.Solayer also supports this service, allowing users to connect and execute transactions directly within a webpage without needing to switch to an external wallet interface or decentralized application (dApp), while also enabling seamless asset deposits and utilization within Solayer for staking, trading, and other DeFi activities.
Solana Actions function similarly to dApp wallet connections, but extend transaction capabilities to any website. With Solana Actions, users can interact with blockchain-based operations directly on a webpage.
Solana Blinks allows any URL to act as an entry point for initiating and signing blockchain transactions. This means users can click a link on social media or embedded in a webpage to interact with Solana smart contracts seamlessly.John Wong, Head of Engineering at Solana Foundation, explains:
“Blockchains often feel isolated from the broader internet. Every online activity should recognize crypto transactions natively—Solana Actions and Blinks make this a reality.”
To enable Solana Actions, developers can send transaction requests to a Solana endpoint. Below is an example function to fetch a signed transaction from a Solana API endpoint.
Copy
import { web3 } from "@coral-xyz/anchor";/** * Fetches a server-signed transaction for restaking SOL. * * @param account - Public key of the user providing the stake. * @param amount - Amount of SOL to stake. * @returns JSON response with the signed transaction. */async function getServerSignedTx( account: web3.PublicKey, amount: string){ return new Promise(async (resolve, reject) => { try { const response = await fetch(`https://app.solayer.org/api/action/restake/ssol?amount=${amount}`, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ account: account.toString() }) }) const res = await response.json(); if (!response.ok) { throw new Error(res?.message || 'error'); } resolve(res); } catch(e) { console.error('Error fetching signed transaction:', e); reject(e); } });}