Execution & Lifecycle
Last updated
Last updated
In previous sections, we've described the URL scheme, the GET
and POST
APIs, and a few other topics as well. Let's now describe the full Action execution flow, which follows a typical HTTP REST API lifecycle:
Here are the steps, listed in the order they occur:
The client makes a GET
request to the Action URL.
The Action API returns a GET
response body of human-readable metadata describing the actions at this URL, according to the specification above.
The user chooses an action to take from the options available, and the client makes a POST
request to the server at the specified URL (which can either be the same as the GET
URL, or different.)
The Action provider receives this request, constructs a transaction or (coming soon!) a message representing the user's action, and returns a POST
response body containing it.
The client takes this transaction and prepares it for the user to sign by sending it to a client-side wallet such as a chrome extension or embedded wallet.
The user signs the transaction (or message), and the client handles submission of this transaction to the blockchain.
Actions providers support validation. GET
and POST
requests may first validate whether the action can be taken, and may customize their response metadata or use disabled
if validation fails.
For example, a GET
request for an NFT that was up for auction may return an error message “This auction has completed” and render the “Bid” button as disabled
if the auction has been completed.
Or a GET
request for a vote on a DAO governance proposal may return the error message “This proposal is no longer up for a vote” and mark the relevant buttons as “disabled” if the voting window has closed.
Once signed, transactions are submitted to the blockchain, and the client is responsible for tracking the execution lifecycle.
An Action's execution state does not persist beyond a single session. If a user refreshes the client, or leaves and comes back at a later time, past or current interactions with the Action will no longer be reflected by the client.