|
|
@@ -1,26 +1,34 @@
|
|
|
---
|
|
|
title: Execute Asset Signing
|
|
|
metaTitle: Execute and Asset Signer | Core
|
|
|
-description: Learn how MPL Core Assets can use the Execute instruction and sign instructions and transcations.
|
|
|
+description: Learn how MPL Core Assets can use the Execute instruction and sign instructions and transactions.
|
|
|
---
|
|
|
|
|
|
-The MPL Core Execute instruction introduces the concept of **Asset Signers** to MPL Core Assets.
|
|
|
+The MPL Core Execute instruction introduces the concept of **Asset Signers** to
|
|
|
+MPL Core Assets.
|
|
|
|
|
|
-These **Asset Signers** act as Signers on behalf of the Asset itself which unlocks the ability for MPL Core Assets
|
|
|
+These **Asset Signers** act as Signers on behalf of the Asset itself which
|
|
|
+unlocks the ability for MPL Core Assets
|
|
|
|
|
|
- to transfer out Solana and SPL Tokens.
|
|
|
- to become the authority of other accounts.
|
|
|
-- to perform other actions and validations that have been assigned to the `assetSignerPda` that require transaction/instruciton/cpi signing.
|
|
|
+- to perform other actions and validations that have been assigned to the
|
|
|
+`assetSignerPda` that require transaction/instruction/CPI signing.
|
|
|
|
|
|
-MPL Core Assets have the ability to sign and submit transactions/cpis to the blockchain. This effecitvely gives the Core Asset it's own wallet in the form of an `assetSigner`.
|
|
|
+MPL Core Assets have the ability to sign and submit transactions/CPIs to the
|
|
|
+blockchain. This effectively gives the Core Asset it's own wallet in the form of
|
|
|
+an `assetSigner`.
|
|
|
|
|
|
## Asset Signer PDA
|
|
|
|
|
|
-Assets are now able to access the `assetSignerPda` account/address which allows the `execute` instruction on the MPL Core program to pass through additional instructions sent to it to sign the cpi instructions with the `assetSignerPda`.
|
|
|
+Assets are now able to access the `assetSignerPda` account/address which allows
|
|
|
+the `execute` instruction on the MPL Core program to pass through additional
|
|
|
+instructions sent to it to sign the CPI instructions with the `assetSignerPda`.
|
|
|
|
|
|
-This allows the `assetSignerPda` account to effectively own and execute account instructions on behalf of the current asset owner.
|
|
|
+This allows the `assetSignerPda` account to effectively own and execute account
|
|
|
+instructions on behalf of the current asset owner.
|
|
|
|
|
|
-You can think of the `assetSignerPda` as a wallet attatched to a Core Asset.
|
|
|
+You can think of the `assetSignerPda` as a wallet attached to a Core Asset.
|
|
|
|
|
|
### findAssetSignerPda()
|
|
|
|
|
|
@@ -34,7 +42,9 @@ const assetSignerPda = findAssetSignerPda(umi, { asset: assetId })
|
|
|
|
|
|
### Overview
|
|
|
|
|
|
-The `execute` instruction allows users to pass in the Core Asset and also some pass through instructions that will get signed by the AssetSigner when it hits the MPL Core programs `execute` instruction on chain.
|
|
|
+The `execute` instruction allows users to pass in the Core Asset and also some
|
|
|
+pass through instructions that will get signed by the AssetSigner when it hits
|
|
|
+the MPL Core programs `execute` instruction on chain.
|
|
|
|
|
|
An overview of the `execute` instruction and it's args.
|
|
|
|
|
|
@@ -56,14 +66,17 @@ const executeTx = await execute(umi, {
|
|
|
### Validation
|
|
|
|
|
|
{% callout title="assetSignerPda Validation" %}
|
|
|
-The MPL Core Execute instruction will validate that the **current Asset owner** has also signed the transaction. This insures only the current Asset Owner can execute transactions while using the `assetSignerPda` with the `execute` instruction.
|
|
|
+The MPL Core Execute instruction will validate that the **current Asset owner**
|
|
|
+has also signed the transaction. This insures only the current Asset Owner can
|
|
|
+execute transactions while using the `assetSignerPda` with the `execute` instruction.
|
|
|
{% /callout %}
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
-### Transfering SOL From the Asset Signer
|
|
|
+### Transferring SOL From the Asset Signer
|
|
|
|
|
|
-In the following example we transfer SOL that had been sent to the `assetSignerPda` to a destination of our choice.
|
|
|
+In the following example we transfer SOL that had been sent to the
|
|
|
+`assetSignerPda` to a destination of our choice.
|
|
|
|
|
|
```js
|
|
|
import {
|
|
|
@@ -114,11 +127,14 @@ const res = await execute(umi, {
|
|
|
console.log({ res })
|
|
|
```
|
|
|
|
|
|
-### Transfering SPL Tokens From the Asset Signer
|
|
|
+### Transferring SPL Tokens From the Asset Signer
|
|
|
|
|
|
-In the following example we transfer some of our SPL Token balance from the `assetSignerPda` account to a destination.
|
|
|
+In the following example we transfer some of our SPL Token balance from the
|
|
|
+`assetSignerPda` account to a destination.
|
|
|
|
|
|
-This example is based on the best practices in regards to derived tokens accounts for a base wallet address. If tokens are not in their correctly derived token account based on the `assetSignerPda` address then this example will need adjusting.
|
|
|
+This example is based on the best practices in regards to derived tokens
|
|
|
+accounts for a base wallet address. If tokens are not in their correctly derived
|
|
|
+token account based on the `assetSignerPda` address then this example will need adjusting.
|
|
|
|
|
|
```js
|
|
|
import {
|
|
|
@@ -180,9 +196,10 @@ const res = await execute(umi, {
|
|
|
console.log({ res })
|
|
|
```
|
|
|
|
|
|
-### Transfering Ownership of an Asset to Another Asset
|
|
|
+### Transferring Ownership of an Asset to Another Asset
|
|
|
|
|
|
-In the following example we transfer a Core Asset that is owned by another Core Asset, to another.
|
|
|
+In the following example we transfer a Core Asset that is owned by another Core
|
|
|
+Asset, to another.
|
|
|
|
|
|
```js
|
|
|
import {
|