Reputation: 35
I'm creating a n umi instance and can't find info on how to define the mySigner const to use in creating the instance. Here's what I got.
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { mplCandyMachine } from "@metaplex-foundation/mpl-candy-machine";
import { publicKey, signerIdentity, KeypairSigner } from "@metaplex-foundation/umi";
const mySigner = ???;
// Use the RPC endpoint of your choice.
export const umi = createUmi(endpoint)
.use(signerIdentity(mySigner))
.use(mplCandyMachine());
thank you, in advanced.
Upvotes: 2
Views: 2496
Reputation: 848
It depends on what you want to use. There are different options:
This results in a newly generated keypair:
const mySigner = generateSigner(umi);
umi.use(keypairIdentity(myKeypairSigner))
you can also import a keypair like this:
const myKeypair = umi.eddsa.createKeypairFromSecretKey(mySecretKey);
const myKeypairSigner = createSignerFromKeypair(umi, myKeypair);
umi.use(keypairIdentity(myKeypairSigner));
If you want to use a wallet (like phantom, backback, Solflare) you should use the normal wallet adapter:
import { walletAdapterIdentity } from "@metaplex-foundation/umi-signer-wallet-adapters";
import { useWallet } from "@solana/wallet-adapter-react";
const wallet = useWallet();
umi.use(walletAdapterIdentity(wallet))
while this creates a dummy Signer based on a public key. (Attention: it can not actually sign but is only a helper
const mySigner = createNoopSigner(myPublicKey);
You can find more info on the signer topic in the umi readme.
Upvotes: 3