> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shinami.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Invisible Wallet API

> App-controlled embedded wallets for a smooth UX

## Overview

Shinami’s Invisible Wallets abstract away Web3 elements like seed phrases, third-party wallet connections, gas fees, and signing popups. They are embedded, backend wallets under the shared custody of your app and Shinami. Both parties must cooperate in order to obtain a valid signature.

You'll find API endpoints and key usage notes below. If you ever need help you can [reach out to us](/help-center/overview#contacting-support).

### Use Cases

Core use cases include app-managed NFTs or closed-loop tokens. For a breakdown of the wallets we offer and wallet use-cases, see our [high-level guide](/product-overviews/sui/wallets#wallet-services-overview).

### Shinami Gas Station Integration

All methods below that write to the Sui blockchain have their gas fees sponsored by you via a Gas Station you create (see the [Sui Gas Station FAQ page of our Help Center](/help-center/sui/gas-station-faq) for how guidance on how to set up a fund and add free Testnet Sui to it). This is because Invisible Wallets are designed to easily onboard Web2-native users (who may not want to download a wallet app, manage a seed phrase, and complete KYC checks to buy SUI for gas).

### Authentication, Rate Limits and Error Handling

**Authentication**

You authenticate via an access key passed in a header ('X-Api-Key: ACCESS\_KEY') or in the request url, e.g. `https://api.us1.shinami.com/sui/wallet/v1/ACCESS_KEY`. We recommend using a request header and not putting access keys in your request URLs for reduced visibility (in logs, etc). These steps are done automatically by our [TypeScript SDK](https://www.npmjs.com/package/@shinami/clients).

For more information, including how to set up an access key with Wallet Services rights, see our [Authentication and API Keys](/developer-guides/core-integration-topics/authentication-and-api-keys) guide.

<Warning>
  **Call this API from your backend**

  Shinami Wallet Services do not support CORS requests, so if you call these APIs from your frontend you'll get a CORS error. This is for security reasons: exposed keys and wallet information could lead to malicious actors signing transactions on behalf of your users.
</Warning>

**Rate Limits**

When you surpass the QPS limit for a key, we return a JSON-RPC error code `-32010`. We recommend implementing retries with a backoff to handle any rate limits errors that arise. You can also [adjust the rate limits of your keys](/developer-guides/core-integration-topics/authentication-and-api-keys#update-a-key%E2%80%99s-qps%2Fcups-values) to better balance your QPS allotment across your keys.

**Error Handling**

See our Error Reference for guidance on the errors you may receive from our services, including a section on errors specific to the [Invisible Wallet API](/developer-guides/core-integration-topics/error-reference#sui-invisible-wallet-api).

### WalletId and Secret Pairing

*When you create an Invisible Wallet, you must create, store, link, and never change the following two values*:

* `walletId`: Your internal id for a wallet. When you provide us a `walletId` in a method call, it tells us which Invisible Wallet to use. It could be your internal `userId` value, or a new arbitrary and unique value you link to the `userId`.
* `secret`: Your internal secret for a wallet. The `sessionToken` you generate with it is combined with Shinami data to obtain a signature from the associated wallet. Ideally it would be different for each wallet so that if one `secret` is compromised the rest are not.

**When you create an Invisible Wallet, you forever link its walletId it to the secret you used:**

<Frame>
  <img src="https://mintcdn.com/shinami/qGR21gGAjbIVFi0T/images/reference/d9a4cea-Creating_a_wallet_2.png?fit=max&auto=format&n=qGR21gGAjbIVFi0T&q=85&s=c485f0bf86ecfe6641d63a36edcb791a" alt="" width="2161" height="737" data-path="images/reference/d9a4cea-Creating_a_wallet_2.png" />
</Frame>

**So, if you try to use the walletId with a different secret, you'll get an error:**

<Frame>
  <img src="https://mintcdn.com/shinami/qGR21gGAjbIVFi0T/images/reference/f6b9121-Getting_an_error.png?fit=max&auto=format&n=qGR21gGAjbIVFi0T&q=85&s=cfb84b1ec8a6953e72c6e238c4406bc5" alt="" width="2161" height="778" data-path="images/reference/f6b9121-Getting_an_error.png" />
</Frame>

### Tutorial with E2E sample code

Check out our [TypeScript tutorial](/developer-guides/sui/tutorials/invisible-wallets) for more code samples and details on the end-to-end flow of creating and using Invisible Wallets to execute sponsored transactions.

## Methods

### shinami\_key\_createSession

For security purposes, you must generate a session token before you create a wallet, or sign or execute transactions. Session tokens are valid and can be reused for 10 minutes.

You may also use an instance of `ShinamiWalletSigner` to manage session token generation and refreshes for a given wallet. This is shown in the methods below that have a `sessionToken` parameter in an additional sample code tab.

**Request Parameters**

| Name   | Type   | Description                                                                                                                                                                                                                                                            |
| :----- | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| secret | string | Used to encrypt and decrypt a wallet's private key. Therefore, it must always be used with the same `walletId` and cannot be changed in the future (see [walletId and secret pairing](/api-docs/sui/wallet-services/invisible-wallet-api#walletid-and-secret-pairing)) |

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.us1.shinami.com/sui/key/v1 \
  -X POST \
  -H 'X-API-Key: {{walletAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc":"2.0",
          "method":"shinami_key_createSession",
          "params":[
              "{{secret}}"
          ],
          "id":1
      }'
  ```

  ```bash Shinami TypeScript SDK theme={null}
  import { KeyClient } from "@shinami/clients/sui";

  const key = new KeyClient({{walletAccessKey}});

  const sessionToken = await key.createSession({{secret}});
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  {
       "jsonrpc":"2.0",
       "result":"eyJraWQiOiJrZXkyMDIzMDgxMSIsImVuYyI6IkEyNTZHQ00iLCJ0YWciOiI4SVpQWXlHeDlmOTd6U2NIdmN6N3lnIiwiYWxnIjoiQTI1NkdDTUtXIiwiaXYiOiJQWVJXZFJrbnNMMlNnVzhfIn0.ygDCI-NcvUcH7wYc0Bp0-59qeIfGOqLyXZGsLF4pW0M.aOAW0AwBvAWpaS-S.QmesdNIdNIYbT59RET-lNuzNMUvS-xb2exhXrAIlspnIkV3nuBx7PKC_GgJ7C1EqJx3tDtQaLLDGdrO8_s-75oK88ls5mzDRR-w2A0VdCcTH0_JwsQgijIbCKFWS0g.dULMzxZ4gGbm2unqOnzv8w",
       "id": 1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  "eyJraWQiOiJrZXkyMDIzMDgxMSIsImVuYyI6IkEyNTZHQ00iLCJ0YWciOiI4SVpQWXlHeDlmOTd6U2NIdmN6N3lnIiwiYWxnIjoiQTI1NkdDTUtXIiwiaXYiOiJQWVJXZFJrbnNMMlNnVzhfIn0.ygDCI-NcvUcH7wYc0Bp0-59qeIfGOqLyXZGsLF4pW0M.aOAW0AwBvAWpaS-S.QmesdNIdNIYbT59RET-lNuzNMUvS-xb2exhXrAIlspnIkV3nuBx7PKC_GgJ7C1EqJx3tDtQaLLDGdrO8_s-75oK88ls5mzDRR-w2A0VdCcTH0_JwsQgijIbCKFWS0g.dULMzxZ4gGbm2unqOnzv8w"
  ```
</CodeGroup>

**Response Fields**

| Name   | Type   | Description                                                                                    |
| :----- | :----- | :--------------------------------------------------------------------------------------------- |
| result | string | `sessionToken` corresponding to the provided `secret`. Valid and can be reused for 10 minutes. |

### shinami\_wal\_createWallet

Programmatically generates a unique wallet for a user that is Sui network agnostic (has the same address on Devnet, Testnet, and Mainnet). On the free tier you have a limit of wallet creations per month as shown on the "Sui Wallet Services" tab of the [billing page](https://app.shinami.com/billing/) in your dashboard (where you can also see how to upgrade if needed). If you hit this limit, you will get a [JSON-RPC code `-32012`](/developer-guides/core-integration-topics/error-reference#sui-invisible-wallet-api) and should not retry. All other wallet operations will still work for the month, like signing with wallets you've already created.

<Warning>
  **Each `walletId` only works with the `secret` you create it with (via the `sessionToken` you pass to this method). Your application MUST remember the (`walletId`, `secret`) pair associated with each Invisible Wallet you create. If you forget or change either of these values, the wallet's private key will be lost and we cannot recover it for you.**
</Warning>

**Request Parameters**

| Name         | Type   | Description                                                                                                                                                                                                                       |
| :----------- | :----- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| walletId     | string | A unique ID you maintain for the wallet. Can be based on your internal user IDs. **Note:** you cannot change this value in the future, so do not use a value that you or your users might change, such as an editable `username`. |
| sessionToken | string | The token generated by `shinami_key_createSession` with the unalterable secret you will permanently associate with this walletId (and, ideally, only this walletId).                                                              |

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.us1.shinami.com/sui/wallet/v1 \
  -X POST \
  -H 'X-API-Key: {{walletAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc": "2.0",
          "method": "shinami_wal_createWallet",
          "params": [
              "{{walletId}}",
              "{{sessionToken}}"
          ],
          "id": 1
      }'
  ```

  ```bash Shinami TypeScript SDK theme={null}
  import { WalletClient } from "@shinami/clients/sui";

  const walletClient = new WalletClient({{walletAccessKey}});

  const walletAddress = await walletClient.createWallet(
      {{walletId}},
      {{sessionToken}}
  );
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner expandable theme={null}
  import {
      WalletClient,
      KeyClient,
      ShinamiWalletSigner
  } from "@shinami/clients/sui";

  const keyClient = new KeyClient({{walletAccessKey}});
  const walletClient = new WalletClient({{walletAccessKey}});

  const signer = new ShinamiWalletSigner(
      {{walletId}},
      walletClient,
      {{walletSecret}},
      keyClient
  );

  // Returns the Sui address of the invisible wallet,
  //  creating it if it hasn't been created yet.
  const CREATE_WALLET_IF_NOT_FOUND = true;
  const walletAddress = await signer.getAddress(CREATE_WALLET_IF_NOT_FOUND);
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  {
      "jsonrpc":"2.0",
      "result":"0xecaeb4a763dd49f2cd13aeaf2e7ab01f704bbc8c2bd9c2e991b726d0632c3b4f",
      "id":1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  "0xecaeb4a763dd49f2cd13aeaf2e7ab01f704bbc8c2bd9c2e991b726d0632c3b4f"
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner expandable theme={null}
  "0xecaeb4a763dd49f2cd13aeaf2e7ab01f704bbc8c2bd9c2e991b726d0632c3b4f"
  ```
</CodeGroup>

**Response Data**

| Type   | Description                                                                                                                                         |
| :----- | :-------------------------------------------------------------------------------------------------------------------------------------------------- |
| String | The Sui address of the Invisible Wallet created for this walletId. Network-agnostic (the address will be the same on Devnet, Testnet, and Mainnet). |

### shinami\_wal\_getWallet

Retrieve a user's wallet address based your unique walletId value for it.

**Request Parameters**

| Name     | Type   | Description                                                   |
| :------- | :----- | :------------------------------------------------------------ |
| walletId | string | Your unique, internal id for the associated Invisible Wallet. |

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.us1.shinami.com/sui/wallet/v1 \
  -X POST \
  -H 'X-API-Key: {{walletAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc":"2.0",
          "method":"shinami_wal_getWallet",
          "params":[
              "{{walletId}}"
          ],
          "id":1
      }'
  ```

  ```bash Shinami TypeScript SDK theme={null}
  import { WalletClient } from "@shinami/clients/sui";

  const walletClient = new WalletClient({{walletAccessKey}});

  const walletAddress = await walletClient.getWallet(
      {{walletId}}
  );
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner expandable theme={null}
  import {
      WalletClient,
      KeyClient,
      ShinamiWalletSigner
  } from "@shinami/clients/sui";

  const keyClient = new KeyClient({{walletAccessKey}});
  const walletClient = new WalletClient({{walletAccessKey}});

  const signer = new ShinamiWalletSigner(
      {{walletId}},
      walletClient,
      {{walletSecret}},
      keyClient
  );

  const walletAddress = await signer.getAddress();
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  {
      "jsonrpc":"2.0",
      "result":"0xecaeb4a763dd49f2cd13aeaf2e7ab01f704bbc8c2bd9c2e991b726d0632c3b4f",
      "id":1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  "0xecaeb4a763dd49f2cd13aeaf2e7ab01f704bbc8c2bd9c2e991b726d0632c3b4f"
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner theme={null}
  "0xecaeb4a763dd49f2cd13aeaf2e7ab01f704bbc8c2bd9c2e991b726d0632c3b4f"
  ```
</CodeGroup>

**Response Fields**

| Type   | Description                                                                                                                                         |
| :----- | :-------------------------------------------------------------------------------------------------------------------------------------------------- |
| String | The Sui address of the Invisible Wallet created for this walletId. Network-agnostic (the address will be the same on Devnet, Testnet, and Mainnet). |

### shinami\_wal\_signTransactionBlock

Signs a fully constructed transaction so that it can be executed. This is a low level API - it requires integration with [Gas Station API](/api-docs/sui/gas-station/api) and [Sui API](/api-docs/sui/node-service/json-rpc/overview) for transaction sponsorship (if needed) and execution. This method gives you more control over how you submit transactions to Sui compared to `shinami_wal_executeGaslessTransactionBlock`, which sponsors, signs, and executes an Invisible Wallet transaction in one method call.

**Request Parameters**

| Name         | Type                                  | Description                                                                                                                                                                                                     |
| :----------- | :------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| walletId     | string                                | Your unique, internal id for the associated Invisible Wallet.                                                                                                                                                   |
| sessionToken | string                                | The token generated by `shinami_key_createSession` with the same secret you used when creating this wallet.                                                                                                     |
| txBytes      | SDK: string \| Uint8ArraycURL: string | BCS serialized TransactionData, which includes gas data. It lacks only the sender's signature (which this method generates) before it can be submitted to the chain. If `string`, assumed to be Base64 encoded. |

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.us1.shinami.com/sui/wallet/v1 \
  -X POST \
  -H 'X-API-Key: {{walletAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc": "2.0",
          "method": "shinami_wal_signTransactionBlock",
          "params": [
              "{{walletId}}",
              "{{sessionToken}}",
              "{{txBytes}}"
        	],
          "id": 1
      }'
  ```

  ```bash Shinami TypeScript SDK theme={null}
  import { WalletClient } from "@shinami/clients/sui";

  const walletClient = new WalletClient({{walletAccessKey}});

  const { signature, txDigest } = await walletClient.signTransaction(
      {{walletId}},
      {{sessionToken}},
      {{txBytes}}
  )
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner expandable theme={null}
  import {
      WalletClient,
      KeyClient,
      ShinamiWalletSigner
  } from "@shinami/clients/sui";

  const keyClient = new KeyClient({{walletAccessKey}});
  const walletClient = new WalletClient({{walletAccessKey}});

  const signer = new ShinamiWalletSigner(
      {{walletId}},
      walletClient,
      {{walletSecret}},
      keyClient
  );

  const { signature, txDigest } = await signer.signTransaction(
      {{txBytes}}
  );
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  {
      "jsonrpc":"2.0",
      "result":{
          "signature":"AKzbe4FlhuT9saKFDUEdmCELBVa/NhsERc2XPahGC+8Ar6YMoK+DH+xs8xg/RSYF7HeZ4UmwnSPJFZpYjgWWZQB51Goyfzm4soRhJY9gDmt/wDZYCm81bkCP87eBm1T+Xw==",
          "txDigest":"BSFD6oDgftrtcVCZF8EAkUcmWWyd8ZRsMCGSh6EbtqCj"
      },
      "id":1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  {
      signature: 'AKzbe4FlhuT9saKFDUEdmCELBVa/NhsERc2XPahGC+8Ar6YMoK+DH+xs8xg/RSYF7HeZ4UmwnSPJFZpYjgWWZQB51Goyfzm4soRhJY9gDmt/wDZYCm81bkCP87eBm1T+Xw==',
      txDigest: 'BSFD6oDgftrtcVCZF8EAkUcmWWyd8ZRsMCGSh6EbtqCj'
  }
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner theme={null}
  {
      signature: 'AKzbe4FlhuT9saKFDUEdmCELBVa/NhsERc2XPahGC+8Ar6YMoK+DH+xs8xg/RSYF7HeZ4UmwnSPJFZpYjgWWZQB51Goyfzm4soRhJY9gDmt/wDZYCm81bkCP87eBm1T+Xw==',
      txDigest: 'BSFD6oDgftrtcVCZF8EAkUcmWWyd8ZRsMCGSh6EbtqCj'
  }
  ```
</CodeGroup>

**Response Fields**

| Name      | Type   | Description                                                                                                                                                                                                                                                                         |
| :-------- | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| signature | string | Base64 encoded transaction signature, signed by the wallet key. To be used alongside the `txBytes` sent to this method and the gas sponsor's signature (if applicable) in a call to [sui\_executeTransactionBlock](/api-docs/sui/node-service/json-rpc#sui-executetransactionblock) |
| txDigest  | string | Base 58 encoded transaction digest.                                                                                                                                                                                                                                                 |

### shinami\_wal\_signPersonalMessage

Signs a personal message using an Invisible Wallet. The signature can be verified with the `PersonalMessage` intent scope. The request template below titled `End-to-end example with ShinamiWalletSigner - Shinami TS SDK` shows an end-to-end example of signing and a message and verifying a signature.

**Request Parameters**

| Name         | Type    | Description                                                                                                                                                                                 |
| :----------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| walletId     | string  | Your unique, internal id for the associated Invisible Wallet.                                                                                                                               |
| sessionToken | string  | The token generated by `shinami_key_createSession` with the same secret you used when creating this wallet.                                                                                 |
| message      | string  | Message bytes to be signed. See an example in the request template below titled `End-to-end example with ShinamiWalletSigner - Shinami TS SDK`                                              |
| wrapBcs      | boolean | Optional. Set it to `true` when calling the API directly to match the verification behavior of the Sui TypeScript SDK. When using the Shinami TypeScript SDK it's set to `true` by default. |

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.us1.shinami.com/sui/wallet/v1 \
  -X POST \
  -H 'X-API-Key: {{walletAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc": "2.0",
          "method": "shinami_wal_signPersonalMessage",
          "params": [
              "{{walletId}}",
              "{{sessionToken}}",
              "{{message}}",
              {{wrapBCs}}
          ],
          "id": 1
      }'
  ```

  ```bash Shinami TypeScript SDK - template theme={null}
  import { WalletClient } from "@shinami/clients/sui";

  const walletClient = new WalletClient({{walletAccessKey}});

  const signature = await walletClient.signPersonalMessage(
      {{walletId}},
      {{sessionToken}},
      {{message}},
      {{wrapBCS}} // optional, defaults to true if not provided
  );
  ```

  ```bash End-to-end example with ShinamiWalletSigner - Shinami TS SDK expandable theme={null}
  import {
      WalletClient,
      KeyClient,
      ShinamiWalletSigner
  } from "@shinami/clients/sui";
  import { verifyPersonalMessage } from '@mysten/sui.js/verify';

  const walletClient = new WalletClient({{walletAccessKey}});
  const key = new KeyClient({{walletAccessKey}});

  const signer = new ShinamiWalletSigner(
      {{walletId}},
      walletClient,
      {{walletSecret}},
      keyClient
  );

  // encode the as a base64 string
  const message = "I have the private keys.";
  const messageAsBase64String = btoa(message);

  // use Shinami Wallet Service to sign the message
  const signature = await signer.signPersonalMessage(
    messageAsBase64String
  );

  // When we check the signature, we encode the message as a byte array
  // and not a base64 string like when we signed it
  const messageBytes = new TextEncoder().encode(message);

  // Failure throws a `Signature is not valid for the provided message` Error
  const publicKey = await verifyPersonalMessage(messageBytes, signature);

  // Get the wallet address we signed with so we can check against it
  const walletAddress = await signer.getAddress();

  console.log(walletAddress == publicKey.toSuiAddress());
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  {
      "jsonrpc":"2.0",
      "result":"AFKIGo7e/eaqCbrrDKIVh4wjpHVudqP8Pbdzo+spztZGmUfiDPY9EPnTx7RnadSQHCSpxgP+QwaAvsJc4JMfswR51Goyfzm4soRhJY9gDmt/wDZYCm81bkCP87eBm1T+Xw==",
      "id":1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  "AFKIGo7e/eaqCbrrDKIVh4wjpHVudqP8Pbdzo+spztZGmUfiDPY9EPnTx7RnadSQHCSpxgP+QwaAvsJc4JMfswR51Goyfzm4soRhJY9gDmt/wDZYCm81bkCP87eBm1T+Xw=="
  ```

  ```bash End-to-end example with ShinamiWalletSigner - Shinami TS SDK theme={null}
  true
  ```
</CodeGroup>

**Response Data**

| Type   | Description                                                                                                            |
| :----- | :--------------------------------------------------------------------------------------------------------------------- |
| string | Base64 encoded signature, produced by the private key of the Invisible Wallet associated with the provided `walletId`. |

### shinami\_wal\_executeGaslessTransactionBlock

Sponsors, signs, and executes a gasless transaction from a wallet. This is a convenient end-to-end method for submitting sponsored transactions to the chain when you also use Shinami Gas Station. It sponsors the transaction using the Gas Station fund tied to the access key used to make the request. To see how to set up an Access Key with rights to all services, see our [Authentication and API Keys guide](/developer-guides/core-integration-topics/authentication-and-api-keys#multiple-services). Note that this call produces a Node service `sui_executeTransactionBlock` request which counts against your daily request total (and so your billing).

**Important notes**

1. **To call this method, you need an access key that is authorized for all of these Shinami products:** Wallet Services, Gas Station, Node Service.
2. **You cannot use the gas object in a sponsored transaction for other purposes:** For example, you cannot write `const [coin] = txb.splitCoins(txb.gas,[txb.pure(100)]);` because it's accessing `txb.gas`. If you try to sponsor a TransactionKind that uses the gas object you will [get a JSON-RPC `-32602` error](/developer-guides/core-integration-topics/error-reference#sui-gas-station-api) back from the Gas Station sponsorship attempt.
3. **Shinami sponsorship fees:** We charge a small fee (in SUI) per sponsorship request to cover our costs. For details, visit the [Billing tab](https://app.shinami.com/billing) in your Shinami dashboard.

**Request Parameters**

| Name                     | Type               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| :----------------------- | :----------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| walletId                 | string             | Your unique, internal id for the associated Invisible Wallet.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| sessionToken             | string             | The token generated by `shinami_key_createSession` with the same secret you used when creating this wallet.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| options                  | object             | [`<TransactionBlockResponseOptions>`](https://github.com/MystenLabs/sui/blob/3699dd3646aec6a6370ecfd2cf957d7b40fbc16d/sdk/typescript/src/client/types/generated.ts#L1320) - Optional. Sui options for specifying the transaction content to be returned                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| requestType (deprecated) | string             | [`<ExecuteTransactionRequestType>`](https://github.com/MystenLabs/sui/blob/3699dd3646aec6a6370ecfd2cf957d7b40fbc16d/sdk/typescript/src/client/types/generated.ts#L266) - Optional. The execution request type (`WaitForEffectsCert` or `WaitForLocalExecution`). Note that calling this method - via our SDK or otherwise - does not have the same result as using the [Mysten SDK v 1.6 and above](https://github.com/MystenLabs/sui/blob/main/sdk/typescript/CHANGELOG.md#160) for `executeTransactionBlock` in that it does not also call `waitForTransaction` to poll the Fullnode to ensure that the transaction has been indexed after execution. If you require read-after-write consistency you will need to explicitly call `waitForTransaction` after calling this method. |
| *SDK-only:* tx           | GaslessTransaction | `TransactionKind` and additional optional data `sender`, `gasBudget`, and `gasPrice`. The result of a call to `buildGaslessTransaction`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| *cURL only:* txBytes     | string             | Base64 encoded `TransactionKind` (as opposed to `TransactionData`) bytes. So, it does not include gas information.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| *cURL only:* gasBudget   | string             | (Optional) The gas budget you wish to use for the transaction, in MIST. The transaction will fail if the gas cost exceeds this value. <br /> <br /> - If provided, we use the value as the budget of the sponsorship. <br /> <br /> - If omitted, we estimate the transaction cost for you. We then add a buffer (5% for non-shared objects, 25% for shared objects) and use that total value as the budget of the sponsorship.                                                                                                                                                                                                                                                                                                                                                      |

**Auto-budgeting notes**

* As a part of auto-budgeting, we put your `transactionBytes` through a [sui\_dryRunTransactionBlock](/api-docs/sui/node-service/json-rpc/write-api#sui-dryruntransactionblock) request as a free service before we attempt to sponsor it. This call will generate error messages for certain invalid transactions, such as if the `transactionBytes` are transferring an object that's not owned by the `sender` address you provide. We'll return these errors back to you, which should be the same as if you had made a `sui_dryRunTransactionBlock` request yourself. We do not do this step if you manually budget, so any issues that would be caught by `sui_dryRunTransactionBlock` will instead produce an error when you try to execute the transaction.
* In the time between sponsorship and execution, shared objects can change in a way that increases their transaction cost. Therefore, we encourage you to execute sponsored transactions quickly, if possible, to ensure that the sponsorship amount is sufficient. This is why we add a larger buffer on auto-budgeted sponsorships when a shared object is involved. While we believe this buffer will work in most cases, we encourage you to monitor the success rate of your auto-budgeted transactions to gauge whether your specific use-case requires manually setting an even larger `gasBudget`.

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL expandable theme={null}
  curl https://api.us1.shinami.com/sui/wallet/v1 \
  -X POST \
  -H 'X-API-Key: {{allServicesAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc": "2.0",
          "method": "shinami_wal_executeGaslessTransactionBlock",
          "params": [
              "{{walletId}}",
              "{{sessionToken}}",
              "{{txBytes}}",
              "{{gasBudget}}",
              {
                  "showInput": false,
                  "showRawInput": false,
                  "showEffects": false,
                  "showEvents": false,
                  "showObjectChanges": false,
                  "showBalanceChanges": false
              },
              "{{requestType}}"
          ],
          "id": 1
      }'
  ```

  ```bash Shinami TypeScript SDK expandable theme={null}
  import { WalletClient } from "@shinami/clients/sui";

  const walletClient = new WalletClient({{allServicesAccessKey}});

  const txResponse = await walletClient.executeGaslessTransaction(
      {{walletId}},
      {{sessionToken}},
      {{tx}}, // if tx.gasBudget is undefined we use our auto-budgeting featur
      {
        	showInput: false,
          showRawInput: false,
          showEffects: false,
          showEvents: false,
          showObjectChanges: false,
          showBalanceChanges: false
      },
      {{requestType}} // must set to `None` or `WaitForLocalExecution` if showEffects, showObjectChanges, or showBalanceChanges are set to true
  );
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner expandable theme={null}
  import {
      WalletClient,
      KeyClient,
      ShinamiWalletSigner
  } from "@shinami/clients/sui";

  const keyClient = new KeyClient({{walletAccessKey}});
  const walletClient = new WalletClient({{walletAccessKey}});

  const signer = new ShinamiWalletSigner(
      {{walletId}},
      walletClient,
      {{walletSecret}},
      keyClient
  );

  const txResponse = await signer.executeGaslessTransaction(
      {{tx}}, // if tx.gasBudget is undefined we use our auto-budgeting feature
      {
          showInput: false,
          showRawInput: false,
          showEffects: false,
          showEvents: false,
          showObjectChanges: false,
          showBalanceChanges: false
      },
      {{requestType}} // must set to `None` or `WaitForLocalExecution` if showEffects, showObjectChanges, or showBalanceChanges are set to true
  );
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  {
      "jsonrpc": "2.0",
      "result": {
          "digest": "Em4C8d6rRSUQ72kUWd627UfXTqDAVWQjJq9tmUFfnrmm",
          "confirmedLocalExecution": true
      },
      "id": 1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  {
      digest: 'B6j8ePkw84R1rpUqxmjaZ3dTuu6GhPdY9MqoSso6kAn7',
      confirmedLocalExecution: true
  }
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner theme={null}
  {
      digest: 'B6j8ePkw84R1rpUqxmjaZ3dTuu6GhPdY9MqoSso6kAn7',
      confirmedLocalExecution: true
  }
  ```
</CodeGroup>

**Response Fields**

| Type                        | Description                                                                                                                                                                                                                  |
| :-------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SuiTransactionBlockResponse | [`<SuiTransactionBlockResponse>`](https://github.com/MystenLabs/sui/blob/3699dd3646aec6a6370ecfd2cf957d7b40fbc16d/sdk/typescript/src/client/types/generated.ts#L1299) containing information about the executed transaction. |

### shinami\_walx\_setBeneficiary

<Info>
  **Beneficiary Graph API**

  This API interacts with the [Account Graph](https://github.com/shinamicorp/account-graph) Move package.
</Info>

Designates a beneficiary account for this wallet in the specified beneficiary graph instance. Calling this method multiple times will override the previous designations.

Apps participating in Bullshark Quests can use this method to link up Shinami Invisible Wallets with their users' self-custody wallets. This way, the user's self-custody wallet (the beneficiary, containing a Bullshark NFT) will get credit for actions done by the associated Invisible Wallet. This method accepts any value that is a possible Sui Address someone could own. It does not guarantee that anyone actually owns a keypair for it and can sign transactions from it (because it does not require the beneficiary address owner to sign a transaction).

This method will use your Shinami Gas Station fund to pay for the transaction. It sponsors the transaction using the Gas Station fund tied to the access key used to make the request. To see how to set up an Access Key with rights to all services, see our [Authentication and API Keys guide](/developer-guides/core-integration-topics/authentication-and-api-keys#multiple-services). Note that this call produces a Node service `sui_executeTransactionBlock` request which counts against your daily request total (and so your billing).

We explicitly wait for the transaction to have been check-pointed and indexed by the Fullnode before returning a response to you to ensure read-after-write consistency.

<Info>
  **To call this method, you need an access key that is authorized for all of these Shinami products:**

  * Wallet Services (for signing the transaction)
  * Gas Station (for sponsoring the transaction)
  * Node Service (for executing the transaction)
</Info>

**Request Parameters**

| Name               | Type   | Description                                                                                                 |
| :----------------- | :----- | :---------------------------------------------------------------------------------------------------------- |
| walletId           | string | Your unique, internal id for the associated invisible wallet whose beneficiary you're setting.              |
| sessionToken       | string | The token generated by `shinami_key_createSession` with the same secret you used when creating this wallet. |
| beneficiaryGraphId | string | `<ObjectID>` - Id of the beneficiary graph instance.                                                        |
| beneficiaryAddress | string | `<SuiAddress>` - Address of the beneficiary account.                                                        |

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL expandable theme={null}
  curl https://api.us1.shinami.com/sui/wallet/v1 \
  -X POST \
  -H 'X-API-Key: {{allServicesAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc": "2.0",
          "method": "shinami_walx_setBeneficiary",
          "params": [
              "{{walletId}}",
              "{{sessionToken}}",
              "{{beneficiaryGraphId}}",
              "{{beneficiaryAddress}}"
          ],
          "id": 1
      }'
  ```

  ```bash Shinami TypeScript SDK theme={null}
  import { WalletClient } from "@shinami/clients/sui";

  const walletClient = new WalletClient({{allServicesAccessKey}});

  const txDigest = await walletClient.setBeneficiary(
      {{walletId}},
      {{sessionToken}},
      {{beneficiaryGraphId}},
      {{beneficiaryAddress}}
  );
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner expandable theme={null}
  import {
      WalletClient,
      KeyClient,
      ShinamiWalletSigner
  } from "@shinami/clients/sui";

  const keyClient = new KeyClient({{walletAccessKey}});
  const walletClient = new WalletClient({{walletAccessKey}});

  const signer = new ShinamiWalletSigner(
      {{walletId}},
      walletClient,
      {{walletSecret}},
      keyClient
  );

  const txDigest = await signer.setBeneficiary(
      {{beneficiaryGraphId}},
      {{beneficiaryAddress}}
  );
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  {
      "jsonrpc":"2.0",
      "result":"43i3D8vhQaJBhDGd1sdQY346w4HjTb79EPv2faNmoSGA",
      "id":1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  "5J671ff8U9CHAABek3PvYDKpYqFcZAVzHJPjp8Nyj3Mp"
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner theme={null}
  "5J671ff8U9CHAABek3PvYDKpYqFcZAVzHJPjp8Nyj3Mp"
  ```
</CodeGroup>

**Response Data**

| Type   | Description                                                    |
| :----- | :------------------------------------------------------------- |
| string | `<TransactionDigest>` - Transaction digest for this operation. |

### shinami\_walx\_unsetBeneficiary

<Info>
  **Beneficiary Graph API**

  This API interacts with the [Account Graph](https://github.com/shinamicorp/account-graph) Move package.
</Info>

Clears any beneficiary designation for this wallet in the specified beneficiary graph instance.

This method will use your Shinami Gas Station fund to pay for the transaction. It sponsors the transaction using the Gas Station fund tied to the access key used to make the request. To see how to set up an Access Key with rights to all services, see our [Authentication and API Keys guide](/developer-guides/core-integration-topics/authentication-and-api-keys#multiple-services). Note that this call produces a Node service `sui_executeTransactionBlock` request which counts against your daily request total (and so your billing).

We explicitly wait for the transaction to have been check-pointed and indexed by the Fullnode before returning a response to you to ensure read-after-write consistency.

<Info>
  **To call this method, you need an access key that is authorized for all of these Shinami products:**

  * Wallet Services
  * Gas Station
  * Node Service
</Info>

**Request Parameters**

| Name               | Type   | Description                                                                                                 |
| :----------------- | :----- | :---------------------------------------------------------------------------------------------------------- |
| walletId           | string | Your unique, internal id for the associated Invisible Wallet whose beneficiary you're unsetting.            |
| sessionToken       | string | The token generated by `shinami_key_createSession` with the same secret you used when creating this wallet. |
| beneficiaryGraphId | string | `<ObjectID>` - Id of the beneficiary graph instance.                                                        |

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL expandable theme={null}
  curl https://api.us1.shinami.com/sui/wallet/v1 \
  -X POST \
  -H 'X-API-Key: {{allServicesAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc": "2.0",
          "method": "shinami_walx_unsetBeneficiary",
          "params": [
              "{{walletId}}",
              "{{sessionToken}}",
              "{{beneficiaryGraphId}}"
          ],
          "id": 1
      }'
  ```

  ```bash Shinami TypeScript SDK theme={null}
  import { WalletClient } from "@shinami/clients/sui";

  const walletClient = new WalletClient({{allServicesAccessKey}});

  const txDigest = await walletClient.unsetBeneficiary(
      {{walletId}},
      {{sessionToken}},
      {{beneficiaryGraphId}}
  );
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner expandable theme={null}
  import {
      WalletClient,
      KeyClient,
      ShinamiWalletSigner
  } from "@shinami/clients/sui";

  const keyClient = new KeyClient({{walletAccessKey}});
  const walletClient = new WalletClient({{walletAccessKey}});

  const signer = new ShinamiWalletSigner(
      {{walletId}},
      walletClient,
      {{walletSecret}},
      keyClient
  );

  const txDigest = await signer.unsetBeneficiary(
      {{beneficiaryGraphId}}
  );
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  {
      "jsonrpc":"2.0",
      "result":"7Ha6scuitsHKETDvShoBa1axv3qdGaspfxFjYdBMDDAQ",
      "id":1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  "5fsyXsmutHWsSnVVqrsNNLnaWRk84pYiwHHhHMZiX4Ea"
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner theme={null}
  "5fsyXsmutHWsSnVVqrsNNLnaWRk84pYiwHHhHMZiX4Ea"
  ```
</CodeGroup>

**Response Data**

| Type   | Description                                                   |
| :----- | :------------------------------------------------------------ |
| string | `<TransactionDigest>` - Transaction digest for this operation |

### shinami\_walx\_getBeneficiary

<Info>
  **Beneficiary Graph API**

  This API interacts with the [Account Graph](https://github.com/shinamicorp/account-graph) Move package.
</Info>

Gets the beneficiary designation for this wallet in the specified beneficiary graph instance. This is a convenience method on top of `suix_getDynamicFieldObject`.

<Info>
  **To call this method, you need an access key that is authorized for all of these Shinami products:**

  * Wallet Services
  * Node Service
</Info>

**Request Parameters**

| Name               | Type   | Description                                                                                       |
| :----------------- | :----- | :------------------------------------------------------------------------------------------------ |
| walletId           | string | Your unique, internal id for the associated Invisible Wallet whose beneficiary you're asking for. |
| beneficiaryGraphId | string | `<ObjectID>` - Id of the beneficiary graph instance                                               |

**Example Request Template**

The TypeScript example uses the [Shinami Clients SDK](https://www.npmjs.com/package/@shinami/clients), which you can install with:

<CodeGroup>
  ```bash Shell theme={null}
  npm install @shinami/clients
  ```
</CodeGroup>

Replace all instances of `{{name}}` with the actual value for that name.

<CodeGroup>
  ```bash cURL expandable theme={null}
  curl https://api.us1.shinami.com/sui/wallet/v1 \
  -X POST \
  -H 'X-API-Key: {walletAndNodeServicesAccessKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
          "jsonrpc": "2.0",
          "method": "shinami_walx_getBeneficiary",
          "params": [
              "{{walletId}}",
              "{{beneficiaryGraphId}}"
          ],
          "id": 1
       }'
  ```

  ```bash Shinami TypeScript SDK theme={null}
  import { WalletClient } from "@shinami/clients/sui";

  const walletClient = new WalletClient({{walletAndNodeServicesAccessKey}});

  const address = await walletClient.getBeneficiary(
      {{walletId}},
      {{beneficiaryGraphId}}
  );
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner expandable theme={null}
  import {
      WalletClient,
      KeyClient,
      ShinamiWalletSigner
  } from "@shinami/clients/sui";

  const keyClient = new KeyClient({{walletAccessKey}});
  const walletClient = new WalletClient({{walletAccessKey}});

  const signer = new ShinamiWalletSigner(
      {{walletId}},
      walletClient,
      {{walletSecret}},
      keyClient
  );

  const address = await signer.getBeneficiary(
      {{beneficiaryGraphId}}
  );
  ```
</CodeGroup>

**Example Response**

<CodeGroup>
  ```bash cURL theme={null}
  // The wallet has a beneficiary in the provided beneficiary graph
  {
      "jsonrpc":"2.0",
      "result":"0xa39edfb89e6a21e89570711845c6c8f412d86bb208e571faf6ea1fc6470172d7",
      "id":1
  }

  // The wallet does not have a beneficiary in the provided beneficiary graph
  {
      "jsonrpc":"2.0",
      "result":null,
      "id":1
  }
  ```

  ```bash Shinami TypeScript SDK theme={null}
  // The wallet has a beneficiary in the provided beneficiary graph
  "0xa39edfb89e6a21e89570711845c6c8f412d86bb208e571faf6ea1fc6470172d7"

  // The wallet does not have a beneficiary in the provided beneficiary graph
  null
  ```

  ```bash Shinami TypeScript SDK using ShinamiWalletSigner theme={null}
  // The wallet has a beneficiary in the provided beneficiary graph
  "0xa39edfb89e6a21e89570711845c6c8f412d86bb208e571faf6ea1fc6470172d7"

  // The wallet does not have a beneficiary in the provided beneficiary graph
  null
  ```
</CodeGroup>

**Response Data**

| Type             | Move Type                                                                                                     | Description                                                                                                               |
| :--------------- | :------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------ |
| string \|\| null | [address](https://github.com/move-language/move/blob/main/language/documentation/book/src/address.md#address) | The network-agnostic Sui address of the Invisible Wallet created for this walletId. Null if no beneficiary is designated. |
