You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to write a contract in which sender can send his Jetton-Token to other account?
MoonAddress is : kQCuxTAQFigrc0jjyU1RvR3otVougTarJRkbAHZ7dCK-YjPs
import "@stdlib/deploy";
import "./jet_ton.tact";
contract Jutt with Deployable {
moonAddress: Address; // Store Moon Jetton contract address
// Initialize with Moon Jetton contract address
init(moonJetton: Address){
self.moonAddress = moonJetton;
}
// Function to transfer Moon tokens using the Jutt contract
receive("transferMoonTokens"){
let senderWallet: Address = self.getSenderJettonWallet(); // Get sender's Jetton wallet
let recipientWallet: Address = self.getRecipientJettonWallet(); // Get recipient's Jetton wallet
let amount: Int = self.getAmount(); // Get the amount to transfer
// Create the transfer message for the sender's Jetton wallet
send(SendParameters{
to: senderWallet,
value: ton("0.1"), // Provide a small amount of TON for gas fees
body: TokenTransfer{
queryId: 0,
amount: amount,
destination: recipientWallet,
response_destination: myAddress(), // Response destination for excess or notifications
custom_payload: null,
forward_ton_amount: ton("0.05"), // Forward TON for recipient's gas
forward_payload: emptySlice() // Additional message/comment if needed
}.toCell()
}
);
dump("Moon tokens transferred successfully");
}
// Example function to get the sender's Jetton wallet address
fun getSenderJettonWallet(): Address {
return self.getJettonWalletAddress(sender()); // Get Jetton wallet for sender
}
// Example function to get the recipient's Jetton wallet address
fun getRecipientJettonWallet(): Address {
let recipient: Address = self.getRecipient(); // Get recipient address
return self.getJettonWalletAddress(recipient); // Get Jetton wallet for recipient
}
// Get recipient address (replace with actual logic)
fun getRecipient(): Address {
return address("0QCBeq_ECrBXkh8mW-0DhNMUmAvkyyDYlBxq1_A4pfiNg3tC"); // recipient address
}
// Example function to get the amount, replace with actual logic
fun getAmount(): Int {
return ton("1000"); // Amount of Moon tokens to transfer
}
// Utility function to get Jetton wallet address based on the owner address
fun getJettonWalletAddress(owner: Address): Address {
let init: StateInit = initOf JettonDefaultWallet(self.moonAddress, owner);
return contractAddress(init);
}
How to write a contract in which sender can send his Jetton-Token to other account?
MoonAddress is : kQCuxTAQFigrc0jjyU1RvR3otVougTarJRkbAHZ7dCK-YjPs
import "@stdlib/deploy";
import "./jet_ton.tact";
contract Jutt with Deployable {
moonAddress: Address; // Store Moon Jetton contract address
}
Look trx:
tonscan: https://testnet.tonscan.org/address/EQDCCLrXNfrszyTQlBjJCAiROUb18XdP7jcwmz63fbNpzi6P
tonviewer:https://testnet.tonviewer.com/kQDCCLrXNfrszyTQlBjJCAiROUb18XdP7jcwmz63fbNpzpUF
I tried but got failed why please help or guide me how to acheive this
The text was updated successfully, but these errors were encountered: