We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
bnUSD is a token contract that burns instead of locks on the source chain when sending cross-chain.
Alice has 1000 bnUSD on Stacks and wants to send 500 bnUSD to Bob's Ethereum address.
(cross-transfer "0x1.eth/0x742d35Cc6634C0532925a3b844Bc454e4438f44e" u500000000 none)
500 bnUSD is burned from Alice's account on Stacks and the following RLP-encoded cross-chain message is sent to Ethereum via xCall.
{ "method": "xCrossTransfer", "from": "0x1.stx/SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7", // Alice's Stacks address "to": "0x1.eth/0x742d35Cc6634C0532925a3b844Bc454e4438f44e", // Bob's Ethereum address "amount": 500000000, "data": null // No additional data }
On Ethereum, the bnUSD contract receives this message and mints 500 bnUSD to Bob's address.
If the transfer fails on Ethereum for any reason, a revert message would be sent back to Stacks to mint 500 bnUSD back to Alice's address:
{ "method": "xCrossTransferRevert", "to": "SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7", // Alice's Stacks address "amount": 500000000 }
Implement RLP encoding/decoding for the following cross-chain messages:
;; Asset Transfer Message ;; For sending assets to other chains (define-data-var transfer-message (tuple (method (string-ascii 13)) ;; "xCrossTransfer" (from (string-ascii 42)) (to (string-ascii 42)) (amount uint) (data (optional (buff 256))) ) ) ;; Asset Transfer Revert Message ;; For handling failed transfers (define-data-var transfer-revert-message (tuple (method (string-ascii 19)) ;; "xCrossTransferRevert" (to principal) (amount uint) ) )
Implement handle-call-message:
handle-call-message
(define-public (handle-call-message (from (string-ascii 64)) (data (buff 1024)) (protocols (list 10 (string-ascii 64)))) (begin ;; Implementation ;; 1. Verify the message source and protocols ;; 2. Decode the message data ;; 3. Route to the appropriate function (transfer or revert) (ok true) ) )
Implement cross-transfer:
cross-transfer
(define-public (cross-transfer (to (string-ascii 42)) (amount uint) (data (optional (buff 256)))) (begin ;; Implementation ;; 1. Burn tokens from sender ;; 2. Prepare cross-chain message ;; 3. Call xCall service to send the message (ok true) ) )
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Overview
bnUSD is a token contract that burns instead of locks on the source chain when sending cross-chain.
Example Usage
Alice has 1000 bnUSD on Stacks and wants to send 500 bnUSD to Bob's Ethereum address.
(cross-transfer "0x1.eth/0x742d35Cc6634C0532925a3b844Bc454e4438f44e" u500000000 none)
500 bnUSD is burned from Alice's account on Stacks and the following RLP-encoded cross-chain message is sent to Ethereum via xCall.
On Ethereum, the bnUSD contract receives this message and mints 500 bnUSD to Bob's address.
If the transfer fails on Ethereum for any reason, a revert message would be sent back to Stacks to mint 500 bnUSD back to Alice's address:
Requirements
Implement RLP encoding/decoding for the following cross-chain messages:
Implement
handle-call-message
:Implement
cross-transfer
:The text was updated successfully, but these errors were encountered: