Last active
January 28, 2022 09:00
-
-
Save Sampriti-Mitra/e938da6aaab88f313f64e322a017d66d to your computer and use it in GitHub Desktop.
Sample go app using thirdweb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/ethereum/go-ethereum/ethclient" | |
"github.com/nftlabs/nftlabs-sdk-go/pkg/nftlabs" | |
"log" | |
"math/big" | |
) | |
func main() { | |
connectToThirdWeb() | |
} | |
func connectToThirdWeb(){ | |
PRIVATE_KEY:="" // you get this from metamask, export private keys for your account | |
nftContractAddress := "" // you get this from the nft module created in thirdweb, just copy the contract address | |
chainRpcUrl := "https://rpc-mumbai.maticvigil.com/" | |
client, err := ethclient.Dial(chainRpcUrl) | |
if err != nil { | |
log.Fatal(err) | |
} | |
sdk, err := nftlabs.NewSdk(client, &nftlabs.SdkOptions{PrivateKey:PRIVATE_KEY}) | |
if err != nil { | |
log.Print("Some error in getting sdk", err) | |
return | |
} | |
// You can get Pack/Marketplace/Collection/Currency contracts the same way | |
nftModule, err := sdk.GetNftModule(nftContractAddress) | |
if err != nil { | |
log.Print("Some error in getting nft module", err) | |
return | |
} | |
metaData,mintErr:=nftModule.MintTo("address_you_want_to_mint_to", nftlabs.MintNftMetadata{ | |
Name: "D'Blog - The Decentralized Blog", | |
Description: "blog", | |
Image: "", // can be an image or an ipfs link | |
Properties: nil, | |
}) | |
if mintErr!=nil{ | |
log.Print("Some error in minting ", mintErr) | |
return | |
} | |
log.Print("nft minted to ", metaData.Id) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment