This repository contains a Sui Move module that implements a generic multi-asset bank. Users can deposit coins of any type and receive a non-transferrable NFT receipt. They can later redeem that receipt to withdraw their deposited funds.
- Generic Deposits: Deposit
Coin<T>
where T can be any coin (e.g., SUI, USDC, USDT) - NFT Receipt: NFT token to represent the deposit
- Withdrawal: Redeem NFT to withdraw the exact amount deposited
- Counters: Tracks total deposits and active NFT receipts
A shared Sui object published once via the init
(or create_asset_bank
for test purposes) function that keeps:
- An unique ID of the bank
- A deposit counter
- A count of currently active (unredeemed) NFTs
An NFT object representing a deposit receipt:
- Non-transferable, only the depositor can redeem it for withdrawal
- Tracks:
deposit_number
depositor
addressamount
-
init_bank(ctx: &mut TxContext)
- Publishes a new
AssetBank
object as a shared object
- Publishes a new
-
deposit<T>(bank: &mut AssetBank, coin: Coin<T>, ctx: &mut TxContext)
- Deposits a
Coin<T>
into the bank - Mints a
Receipt<T>
NFT and sends to the depositor
- Deposits a
-
withdraw<T>(bank: &mut AssetBank, receipt: Receipt<T>, ctx: &mut TxContext)
- Burns the NFT (i.e.
Receipt<T>
) and returns the original deposit
- Burns the NFT (i.e.
- Publish Module
sui move build sui move test sui client publish --gas-budget <GAS_BUDGET>