Comments (10)
sorry for the late.
I think you can use this code to mint NFT first.
package main
import (
"context"
"fmt"
"log"
"github.com/portto/solana-go-sdk/client"
"github.com/portto/solana-go-sdk/common"
"github.com/portto/solana-go-sdk/program/assotokenprog"
"github.com/portto/solana-go-sdk/program/metaplex/tokenmeta"
"github.com/portto/solana-go-sdk/program/sysprog"
"github.com/portto/solana-go-sdk/program/tokenprog"
"github.com/portto/solana-go-sdk/rpc"
"github.com/portto/solana-go-sdk/types"
)
func main() {
c := client.NewClient(rpc.DevnetRPCEndpoint)
// init your fee payer
feePayer, _ = types.AccountFromBase58("")
mintMinBalance, _ := c.GetMinimumBalanceForRentExemption(context.Background(), 82)
mint := types.NewAccount()
ata, _, _ := common.FindAssociatedTokenAddress(feePayer.PublicKey, mint.PublicKey)
tokenMetadataPubkey, _ := tokenmeta.GetTokenMetaPubkey(mint.PublicKey)
tokenMasterEditionPubkey, _ := tokenmeta.GetMasterEdition(mint.PublicKey)
sig, err := c.QuickSendTransaction(context.Background(), client.QuickSendTransactionParam{
FeePayer: feePayer.PublicKey,
Signers: []types.Account{mint, feePayer},
Instructions: []types.Instruction{
sysprog.CreateAccount(sysprog.CreateAccountParam{
From: feePayer.PublicKey,
New: mint.PublicKey,
Owner: common.TokenProgramID,
Lamports: mintMinBalance,
Space: 82,
}),
tokenprog.InitializeMint(tokenprog.InitializeMintParam{
Decimals: 0,
Mint: mint.PublicKey,
MintAuth: feePayer.PublicKey,
}),
tokenmeta.CreateMetadataAccount(tokenmeta.CreateMetadataAccountParam{
Metadata: tokenMetadataPubkey,
Mint: mint.PublicKey,
MintAuthority: feePayer.PublicKey,
Payer: feePayer.PublicKey,
UpdateAuthority: feePayer.PublicKey,
UpdateAuthorityIsSigner: true,
IsMutable: true,
MintData: tokenmeta.Data{
Name: "",
Symbol: "",
Uri: "",
SellerFeeBasisPoints: 100,
Creators: &[]tokenmeta.Creator{
{
Address: feePayer.PublicKey,
Verified: true,
Share: 100,
},
},
},
}),
assotokenprog.CreateAssociatedTokenAccount(assotokenprog.CreateAssociatedTokenAccountParam{
Funder: feePayer.PublicKey,
Owner: feePayer.PublicKey,
Mint: mint.PublicKey,
AssociatedTokenAccount: ata,
}),
tokenprog.MintTo(tokenprog.MintToParam{
Mint: mint.PublicKey,
To: ata,
Auth: feePayer.PublicKey,
Amount: 1,
}),
tokenmeta.CreateMasterEdition(tokenmeta.CreateMasterEditionParam{
Edition: tokenMasterEditionPubkey,
Mint: mint.PublicKey,
UpdateAuthority: feePayer.PublicKey,
MintAuthority: feePayer.PublicKey,
Metadata: tokenMetadataPubkey,
Payer: feePayer.PublicKey,
MaxSupply: nil,
}),
},
})
if err != nil {
log.Fatalf("failed to send tx, err: %v", err)
}
fmt.Println(sig)
}
from solana-go-sdk.
mints NFT and purchases NFT on magic eden are different things.
for mint NFT I can add some examples because I know how metaplex's program writes.
for magic eden's purchasing, I need to know how magic eden serialize its instructions. it will take some time.
from solana-go-sdk.
mints NFT and purchases NFT on magic eden are different things. for mint NFT I can add some examples because I know how metaplex's program writes. for magic eden's purchasing, I need to know how magic eden serialize its instructions. it will take some time.
That would be super helpful either way if thats possible!
from solana-go-sdk.
Hi, would we able to get more info on this? Really loving this library, thank you!
from solana-go-sdk.
Awesome thank you! Still getting used to interacting with Solana/ its terminology. This seems like code to create new tokens on the blockchain. Would one be able to use this code to also mint an NFT from someone else's program? (for example: metaplex candymachine v2)
from solana-go-sdk.
This seems like code to create new tokens on the blockchain.
Basically all process of minting NFT is based on this. 1) create mint 2) mint 1 token 3) init metadata and master edition (option). You will find some difference in each program but the main process is the same.
Would one be able to use this code to also mint an NFT from someone else's program?
this code is to call metaplex token metadata program directly.
candy machine v2 is a different program. If you want to interact with it. You need to compose instructions by yourself (this lib is not support atm).
from solana-go-sdk.
So for a non-candymachine NFT, that has already been created using the instructions from above, how would I go about minting a token using only code after it has been created?
from solana-go-sdk.
When you create a master edition. You also specific a limit amount which can be copied.
The main idea is to use tokenmeta.MintNewEditionFromMasterEditionViaToken
for now you can take a look at these code.
package main
import (
"context"
"fmt"
"log"
"github.com/portto/solana-go-sdk/client"
"github.com/portto/solana-go-sdk/common"
"github.com/portto/solana-go-sdk/program/assotokenprog"
"github.com/portto/solana-go-sdk/program/metaplex/tokenmeta"
"github.com/portto/solana-go-sdk/program/sysprog"
"github.com/portto/solana-go-sdk/program/tokenprog"
"github.com/portto/solana-go-sdk/rpc"
"github.com/portto/solana-go-sdk/types"
)
func main() {
var feePayer, _ = types.AccountFromBytes()
c := client.NewClient(rpc.DevnetRPCEndpoint)
masterEdition := common.PublicKeyFromString("")
metadata := common.PublicKeyFromString("")
metadataMint := common.PublicKeyFromString("") // master NFT
oriTokenAccount, _, _ := common.FindAssociatedTokenAddress(feePayer.PublicKey, metadataMint)
mintMinBalance, _ := c.GetMinimumBalanceForRentExemption(context.Background(), 82)
mint := types.NewAccount()
var edition uint64 = 1
ata, _, _ := common.FindAssociatedTokenAddress(feePayer.PublicKey, mint.PublicKey)
tokenMetadataPubkey, _ := tokenmeta.GetTokenMetaPubkey(mint.PublicKey)
tokenMasterEditionPubkey, _ := tokenmeta.GetMasterEdition(mint.PublicKey)
editionMark, _ := tokenmeta.GetEditionMark(metadataMint, edition)
fmt.Println(editionMark.ToBase58())
sig, err := c.QuickSendTransaction(context.Background(), client.QuickSendTransactionParam{
FeePayer: feePayer.PublicKey,
Signers: []types.Account{mint, feePayer},
Instructions: []types.Instruction{
sysprog.CreateAccount(sysprog.CreateAccountParam{
From: feePayer.PublicKey,
New: mint.PublicKey,
Owner: common.TokenProgramID,
Lamports: mintMinBalance,
Space: 82,
}),
tokenprog.InitializeMint(tokenprog.InitializeMintParam{
Decimals: 0,
Mint: mint.PublicKey,
MintAuth: feePayer.PublicKey,
}),
assotokenprog.CreateAssociatedTokenAccount(assotokenprog.CreateAssociatedTokenAccountParam{
Funder: feePayer.PublicKey,
Owner: feePayer.PublicKey,
Mint: mint.PublicKey,
AssociatedTokenAccount: ata,
}),
tokenprog.MintTo(tokenprog.MintToParam{
Mint: mint.PublicKey,
To: ata,
Auth: feePayer.PublicKey,
Amount: 1,
}),
tokenmeta.MintNewEditionFromMasterEditionViaToken(tokenmeta.MintNewEditionFromMasterEditionViaTokeParam{
NewMetaData: tokenMetadataPubkey,
NewEdition: tokenMasterEditionPubkey,
MasterEdition: masterEdition,
NewMint: mint.PublicKey,
EditionMark: editionMark,
NewMintAuthority: feePayer.PublicKey,
Payer: feePayer.PublicKey,
TokenAccountOwner: feePayer.PublicKey,
TokenAccount: oriTokenAccount,
NewMetadataUpdateAuthority: feePayer.PublicKey,
MasterMetadata: metadata,
Edition: edition,
}),
},
})
if err != nil {
log.Fatalf("failed to send tx, err: %v", err)
}
fmt.Println(sig)
}
from solana-go-sdk.
https://portto.github.io/solana-go-sdk/nft/mint-a-nft.html
from solana-go-sdk.
When you create a master edition. You also specific a limit amount which can be copied. The main idea is to use
tokenmeta.MintNewEditionFromMasterEditionViaToken
for now you can take a look at these code.
package main import ( "context" "fmt" "log" "github.com/portto/solana-go-sdk/client" "github.com/portto/solana-go-sdk/common" "github.com/portto/solana-go-sdk/program/assotokenprog" "github.com/portto/solana-go-sdk/program/metaplex/tokenmeta" "github.com/portto/solana-go-sdk/program/sysprog" "github.com/portto/solana-go-sdk/program/tokenprog" "github.com/portto/solana-go-sdk/rpc" "github.com/portto/solana-go-sdk/types" ) func main() { var feePayer, _ = types.AccountFromBytes() c := client.NewClient(rpc.DevnetRPCEndpoint) masterEdition := common.PublicKeyFromString("") metadata := common.PublicKeyFromString("") metadataMint := common.PublicKeyFromString("") // master NFT oriTokenAccount, _, _ := common.FindAssociatedTokenAddress(feePayer.PublicKey, metadataMint) mintMinBalance, _ := c.GetMinimumBalanceForRentExemption(context.Background(), 82) mint := types.NewAccount() var edition uint64 = 1 ata, _, _ := common.FindAssociatedTokenAddress(feePayer.PublicKey, mint.PublicKey) tokenMetadataPubkey, _ := tokenmeta.GetTokenMetaPubkey(mint.PublicKey) tokenMasterEditionPubkey, _ := tokenmeta.GetMasterEdition(mint.PublicKey) editionMark, _ := tokenmeta.GetEditionMark(metadataMint, edition) fmt.Println(editionMark.ToBase58()) sig, err := c.QuickSendTransaction(context.Background(), client.QuickSendTransactionParam{ FeePayer: feePayer.PublicKey, Signers: []types.Account{mint, feePayer}, Instructions: []types.Instruction{ sysprog.CreateAccount(sysprog.CreateAccountParam{ From: feePayer.PublicKey, New: mint.PublicKey, Owner: common.TokenProgramID, Lamports: mintMinBalance, Space: 82, }), tokenprog.InitializeMint(tokenprog.InitializeMintParam{ Decimals: 0, Mint: mint.PublicKey, MintAuth: feePayer.PublicKey, }), assotokenprog.CreateAssociatedTokenAccount(assotokenprog.CreateAssociatedTokenAccountParam{ Funder: feePayer.PublicKey, Owner: feePayer.PublicKey, Mint: mint.PublicKey, AssociatedTokenAccount: ata, }), tokenprog.MintTo(tokenprog.MintToParam{ Mint: mint.PublicKey, To: ata, Auth: feePayer.PublicKey, Amount: 1, }), tokenmeta.MintNewEditionFromMasterEditionViaToken(tokenmeta.MintNewEditionFromMasterEditionViaTokeParam{ NewMetaData: tokenMetadataPubkey, NewEdition: tokenMasterEditionPubkey, MasterEdition: masterEdition, NewMint: mint.PublicKey, EditionMark: editionMark, NewMintAuthority: feePayer.PublicKey, Payer: feePayer.PublicKey, TokenAccountOwner: feePayer.PublicKey, TokenAccount: oriTokenAccount, NewMetadataUpdateAuthority: feePayer.PublicKey, MasterMetadata: metadata, Edition: edition, }), }, }) if err != nil { log.Fatalf("failed to send tx, err: %v", err) } fmt.Println(sig) }
Can you add this example to the document?
from solana-go-sdk.
Related Issues (20)
- how to decode the instruction.data? HOT 1
- how to getTokenAccountOwner HOT 3
- how to get the mint name of 7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx HOT 3
- How to get SOL transfers from a response getTransaction() HOT 2
- creating a new wallet and other things HOT 1
- Cant understand how to give instructions for Launchmynft.io
- Cant understand how to give instructions for raydium swap HOT 2
- How to create stake account? HOT 2
- [HELP] Deserializing AccountData data field into address lookup tables
- UpdateMetadataAccount returning deprecated error HOT 2
- Any plan to support anchor? HOT 3
- Websocket API support
- How do I initiate a USDT SPL transfer transaction? HOT 4
- Add Priority Fee to Transaction HOT 1
- How do I initiate a USDT SPL transfer transaction? HOT 3
- An optimization suggestion about transaction serialization
- Add unitsConsumed field to RPC simulateTransaction response HOT 1
- GetSlotLeader HOT 2
- Add GetSlotLeaders HOT 1
- Add GetProgramAccounts method to the client folder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solana-go-sdk.