In this quickstart, you will create new user wallets on Story.

This quickstart is under development as new features are added to the Story Protocol daily.

Preparation Steps

1

Create a Developer Account and Project

To get started, create a developer account in the Crossmint Staging Console. Open that link, sign in, and accept the dialog to continue.

Crossmint offers two consoles: staging, for development and testing, and www, for production.

Then, navigate to project Settings > General and set the wallet type to “Smart Wallets”:

2

Get an API Key

Create a server-side API key with these scopes: wallets.create, wallets:transactions.create, wallets:transactions.sign.

This allows your API key to create new server wallets.

Create Server Wallets

1

Choose a Wallet Type

Below is a summary of available wallet types and their characteristics:

CustodialTypeAdmin Signer
Trueevm-smart-walletevm-fireblocks-custodial
Falseevm-smart-walletevm-keypair
2

Create a Wallet

const response = await fetch("https://staging.crossmint.com/api/2022-06-09/wallets", {
    method: "POST",
    headers: {
        "X-API-KEY": "<YOUR_API_KEY>",
        "Content-Type": "application/json",
    },
    body: JSON.stringify({
        type: "<WALLET_TYPE>",
        // Here you can pass a user ID, email, phone number, twitter handle etc. depending on how the user is identified in your application
        linkedUser: "email:user@example.com",
        config:{
            adminSigner: {type: "<ADMIN_SIGNER>"},
        }
    }),
});

const wallet = await response.json();
console.log("Wallet created:", wallet);

Now, run the script:

npx tsx createWallet.ts

Send Arbitrary Transaction

1

Prepare the transaction

Set up a Story Protocol client using the wallet created in the previous step and prepare a transaction to create a new NFT collection

const client = StoryClient.newClient({
    transport: http(RPC_PROVIDER_URL),
    account: wallet.address,
});

const creationTx = await client.nftClient.createNFTCollection({
    name: "A collection of IP fantasy assets",
    symbol: "XMT",
    contractURI: "ipfs://QmXYnQJjUxojhh6NKkxPkcXNKFo4pU2hxUyJjqzTcQL9rE",
    isPublicMinting: true,
    mintOpen: true,
    mintFeeRecipient: wallet.address,
    txOptions: {
        encodedTxDataOnly: true,
    },
});
2

Send the transaction

Send the prepared transaction to Crossmint’s API, which handles the blockchain interaction. The transaction creates the NFT collection on Story Protocol’s network without requiring user’s signature or handling of gas fees.

const response = await fetch(`https://staging.crossmint.com/api/2022-06-09/wallets/${wallet.address}/transactions`, {
    method: "POST",
    headers: {
        "X-API-KEY": "<YOUR_API_KEY>",
        "Content-Type": "application/json",
    },
    body: JSON.stringify({
        params: {
            call: {
                // Encoded transaction data
                data: creationTx.encodedTxData.data,
                // Transaction destination
                to: creationTx.encodedTxData.to,
            },
            chain: "story-testnet",
        },
    }),
});

const transaction = await response.json();
console.log("Transaction created:", transaction.id);

Story Protocol transactions through Crossmint smart wallets are completely gas-free! You can focus on building your application without worrying about managing gas fees or token balances.

3

Monitor Transaction Status

Check the transaction status using the transaction ID.

const response = await fetch(
    `https://staging.crossmint.com/api/2022-06-09/wallets/${wallet.address}/transactions/${transaction.id}`,
    {
        method: "GET",
        headers: {
            "X-API-KEY": "<YOUR_API_KEY>",
        },
    }
);

const status = await response.json();
console.log("Status:", status.status);