Introduction
In the realm of TON Blockchain (The Open Network), smart contracts play a pivotal role in enhancing the efficiency and security of transactions. One such innovative smart contract is the Ton Proxy Contract, designed to forward internal messages seamlessly. This post delves into the technicalities of this contract, its data cell scheme, and its practical applications, particularly in managing Jetton deposits.
Ton Proxy Contract Overview
The Ton Proxy Contract is engineered to forward internal messages by sending the body refs of incoming internal messages as internal messages with a specific mode (128+32). This mode ensures the forwarding of all TONs from the balance and triggers self-destruction of the contract. For the contract to accept an incoming internal message, the message must contain an initialization segment.
Contract Data Cell Scheme
The data structure of the Ton Proxy Contract is encapsulated in the following scheme:
data owner:MsgAddressInt subwallet_id:uint32 = Data;
Use Cases
Jetton Deposits Control
The Ton Proxy Contract finds its utility in managing Jetton deposits. By employing a single wallet, users can create multiple Jetton deposits. For each Jetton wallet, a proxy contract is instantiated with the Jetton wallet as its owner. Consequently, managing multiple Jetton wallets becomes streamlined by sending messages to their respective proxy contracts.
Technical Implementation
The core functionality of receiving and forwarding internal messages is encapsulated in the following code snippet:
int equal_slices (slice a, slice b) asm "SDEQ";
() recv_internal (int balance, int msg_value, cell in_msg_full, slice in_msg_body) {
slice cs = in_msg_full.begin_parse();
int flags = cs~load_uint(4);
if (flags & 1) { ;; ignore all bounced messages
return ();
}
slice sender_address = cs~load_msg_addr();
slice ds = get_data().begin_parse();
slice owner_address = ds~load_msg_addr();
throw_unless(403, equal_slices(sender_address, owner_address));
while (in_msg_body.slice_refs()) {
send_raw_message(in_msg_body~load_ref(), 160);
}
}
Conclusion
The Ton Proxy Contract exemplifies the innovative approaches in TON Blockchain to enhance transaction efficiency and security. By enabling streamlined management of Jetton deposits and forwarding internal messages, this smart contract paves the way for more sophisticated blockchain solutions.
For further reading and technical details, visit the TON Blockchain Documentation.
Discussion
Feel free to share your thoughts and experiences with the Ton Proxy Contract in the comments below. Letβs explore the potential of this technology together!