0

I'm trying to build a tx for the client to sign that will delegate the pNFT to a new address. I am using Metaplex's Umi and the walletAdapterIdentity plugin.

I'm getting an error when I try to run my code and call the handleDelegate (delegateStakingV1) function.

The error I'm getting is related to the walletAdapterIdentity plugin:

> TypeError: publicKey.toBase58 is not a function

I believe I have the umi.identity setup properly, and I am stumped on this error.

Ideally I would like to be able to use the walletAdapterIdentity and sign the transaction via Phantom/Solflare.

Here is my VueJs code I'm working on:

<script setup>
import { ref, computed, watch } from 'vue'
import { WalletMultiButton, useWallet } from "solana-wallets-vue"
import { Connection, PublicKey } from '@solana/web3.js'
import { signerIdentity, publicKey, generateSigner, transactionBuilder } from '@metaplex-foundation/umi';
import { Metaplex, IdentityClient } from "@metaplex-foundation/js";
import { walletAdapterIdentity } from "@metaplex-foundation/umi-signer-wallet-adapters";
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { delegateStakingV1, mplTokenMetadata, TokenStandard } from '@metaplex-foundation/mpl-token-metadata';

const connection = new Connection(rpc);
const wallet = useWallet();
const umi = createUmi(connection).use(mplTokenMetadata()).use(walletAdapterIdentity(wallet))

const handleDelegate = async () => {
    const signer = umi.identity
    console.log("Signer:", signer)
    if (wallet.publicKey && wallet.publicKey.value) {
        try {
            const mint = new PublicKey('mintPublicKeyString');
            const stakingDelegate = new PublicKey('walletPublicKeyString');
            const signer = umi.identity

            const transaction = transactionBuilder()
                .add(delegateStakingV1(umi, {
                    mint: mint,
                    tokenOwner: signer.publicKey,
                    authority: signer,
                    authorizationRules: new PublicKey('eBJLFYPxJmMGKuFwpDWkzxZeUrad92kZRC5BJLpzyT9'),
                    delegate: stakingDelegate,
                    tokenStandard: TokenStandard.ProgrammableNonFungible,
                }))

            const { signature } = await transaction.sendAndConfirm(umi, {
                confirm: { commitment: "finalized" }, send: {
                    skipPreflight: true,
                },
            });
            console.log("Signature:", signature)

        } catch (error) {
            console.error('Delegate error:', error);
        }
    } else {
        console.log("Wallet not connected");
    }
};

</script>

<template>
    <div data-theme="dark" class="font-mono">
        <div class="h-screen bg-base-300">
            <wallet-multi-button dark></wallet-multi-button>

            <div class="absolute top-16 right-4 space-y-4 text-white">
                <div class="w-16 border border-black/5 hover:cursor-pointer hover:scale-105" @click="handleDelegate">
                    <img src="../assets/img/storage-unit.png" />
                    <p class="text-xs text-orange-400 text-center">Stake</p>
                </div>
            </div>
        </div>
    </div>
</template>

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.