Back to Sway

Wallet

docs/reference/src/documentation/examples/wallet.md

0.71.0639 B
Original Source

Wallet

The following example implements a wallet that utilizes the base asset.

ABI

The interface contains a function which tracks the amount of the base asset received and a function to transfer the funds.

sway
{{#include ../../code/examples/wallet_example/src/main.sw:abi}}

Implementation

When receiving funds we assert that the wallet accepts the base asset and we track the amount sent. When transferring funds out of the wallet we assert that only the owner can perform the transfer.

sway
{{#include ../../code/examples/wallet_example/src/main.sw:implementation}}