blocto / solana-go-sdk

Solana Golang SDK
https://blocto.github.io/solana-go-sdk/
MIT License
410 stars 109 forks source link

Cant understand how to give instructions for Launchmynft.io #150

Open nglmq opened 11 months ago

nglmq commented 11 months ago

`package main

import ( "context" "fmt" "log"

"github.com/blocto/solana-go-sdk/client"
"github.com/blocto/solana-go-sdk/common"
"github.com/blocto/solana-go-sdk/program/system"
"github.com/blocto/solana-go-sdk/program/token"
"github.com/blocto/solana-go-sdk/rpc"
"github.com/blocto/solana-go-sdk/types"

)

// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz var feePayer, _ = types.AccountFromBase58("MY-PRIVATE")

// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde var alice, _ = types.AccountFromBase58("J85nmRGigs4dovRGcXDiuzikeEb9ST9fDV71che8HRvu") //CMID of launchmynft collection

func main() { c := client.NewClient(rpc.MainnetRPCEndpoint)

// create an mint account
mint := types.NewAccount()
fmt.Println("mint:", mint.PublicKey.ToBase58())

// get rent
rentExemptionBalance, err := c.GetMinimumBalanceForRentExemption(
    context.Background(),
    token.MintAccountSize,
)
if err != nil {
    log.Fatalf("get min balacne for rent exemption, err: %v", err)
}

res, err := c.GetLatestBlockhash(context.Background())
if err != nil {
    log.Fatalf("get recent block hash error, err: %v\n", err)
}

tx, err := types.NewTransaction(types.NewTransactionParam{
    Message: types.NewMessage(types.NewMessageParam{
        FeePayer:        feePayer.PublicKey,
        RecentBlockhash: res.Blockhash,
        Instructions: []types.Instruction{
            system.CreateAccount(system.CreateAccountParam{
                From:     feePayer.PublicKey,
                New:      mint.PublicKey,
                Owner:    common.TokenProgramID,
                Lamports: rentExemptionBalance,
                Space:    token.MintAccountSize,
            }),
            token.InitializeMint(token.InitializeMintParam{
                Decimals:   8,
                Mint:       mint.PublicKey,
                MintAuth:   alice.PublicKey,
                FreezeAuth: nil,
            }),
        },
    }),
    Signers: []types.Account{feePayer, mint},
})
if err != nil {
    log.Fatalf("generate tx error, err: %v\n", err)
}

txhash, err := c.SendTransaction(context.Background(), tx)
if err != nil {
    log.Fatalf("send tx error, err: %v\n", err)
}

log.Println("txhash:", txhash)

} `

can you help me.....

As i know launchmynft cmid is image and token programm owner image

THIS IS SUCCESS MINT TRANSACTION https://solscan.io/tx/3BLtM5kNPRqJ8zj86xccvhNyLq4UvMS9RJqz566wpZRRPq5UZrjoss6X9fP2j7u1qeyqhTB6uArVZSHjATz6MJxW https://solscan.io/tx/2bQFHTJP2eNUMYZ2fAQBgfQc4FQTZq8ha6BbpeMZKZ917ndPax2BBc41j6NsrTZyZXEEv5KErRGkACtt5PKPox9i