Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mint jetton #231

Open
maiganne opened this issue Aug 5, 2024 · 4 comments
Open

mint jetton #231

maiganne opened this issue Aug 5, 2024 · 4 comments

Comments

@maiganne
Copy link

maiganne commented Aug 5, 2024

Can you provide an example of a mint jetton?

@xssnick
Copy link
Owner

xssnick commented Aug 6, 2024

Hi, you can send message with this payload to jetton master contract, similar to this example But mint payloads also can depend on specific master jetton implementation, so maybe you will need your own

@zy166317
Copy link

zy166317 commented Sep 2, 2024

Can you provide an example of a mint jetton?

I also have the same problem. Is there any solution?

@zy166317
Copy link

zy166317 commented Sep 3, 2024

@maiganne I also have the same problem. Is there any solution?

@Galiks
Copy link

Galiks commented Sep 27, 2024

@zy166317

client := liteclient.NewConnectionPool()
ctx := client.StickyContext(context.Background())
configUrl := "https://ton-blockchain.github.io/testnet-global.config.json"
err := client.AddConnectionsFromConfigUrl(ctx, configUrl)
if err != nil {
	panic(err)
}
api := ton.NewAPIClient(client)
walletWord := strings.Split(`<<spec words>>`, " ")
my_wallet, err := wallet.FromSeed(api, walletWord, wallet.V4R2)
if err != nil {
	panic(err)
}
minterAddress := address.MustParseAddr("<<On-chain smart contract address of the Jetton parent (jetton-minter.fc)>>") // https://minter.ton.org/jetton/<<Jetton address>>
recipientAddress := my_wallet.Address()

buf := make([]byte, 8)
if _, err := rand.Read(buf); err != nil {
	panic(err)
}
rnd := binary.LittleEndian.Uint64(buf)
jm := jetton.MintPayload{
	QueryID:   rnd,
	ToAddress: recipientAddress,
	MasterMsg: jetton.MintPayloadMasterMsg{
		Opcode:       21,
		QueryID:      rnd,
		JettonAmount: tlb.MustFromTON("100"),
		RestData:     &cell.Cell{},
	},
}
payload, err := tlb.ToCell(jm)
if err != nil {
	panic(err)
}
txHash, _, err := my_wallet.SendWaitTransaction(ctx, &wallet.Message{
	Mode: 1,
	InternalMessage: &tlb.InternalMessage{
		IHRDisabled: true,
		Bounce:      true,
		Bounced:     true,
		SrcAddr:     my_wallet.Address(),
		DstAddr:     minterAddress,
		Amount:      tlb.MustFromTON("0.05"),
		Body:        payload,
	},
})
if err != nil {
	log.Fatalf("failed to send transaction: %v", err)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants