- use CLI in
contracts/crossfader
- Don't forget to remove
[addresses]
field in Move.toml before your deployment
aptos move create-resource-account-and-publish-package --seed 1235 --address-name ra_addr --named-addresses origin_account=[YOUR_ACCOUNT_ADDRESS]
- It creates a resource acccount with the given seed.
- It publishes package. When the package published, your account loses the control of resource account.
init_module
is called when it published
Reference)
aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::init_vaults --type-args 0x1::aptos_coin::AptosCoin
It is another step for initializing the contract. It needs just to be called once in Crossfader. Every user uses the same module. It is totally safe because nobody has a control over the resource account module.
With the type args, Crossfader can be used for any coins!
aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::initialize --type-args 0x1::aptos_coin::AptosCoin --args address:0x1223334444 u64:10000
It is called for each user. In a command line interface, don't forget to create the second account. Absolutely, users don't need to create it. Crossfader's server will create it and secure it with users' SSO auth :D
aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::deposit --type-args 0x1::aptos_coin::AptosCoin --args u64:100000
aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::request_withdraw --type-args 0x1::aptos_coin::AptosCoin --args address:0x12351131234 u64:5000
Withdrawal limitation is 10000, so you can use your 5000 APT only with your account signature.
aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::request_withdraw --type-args 0x1::aptos_coin::AptosCoin --args address:0x12351131234 u64:6000
Withdrawal sum exceeded the limit! You need another approval with Crossfader's safe 2FA.
Fyi, the sum is calculated among 1 day.
aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::deposit --type-args 0x1::aptos_coin::AptosCoin --args address:[YOUR ACCOUNT ADDRESS] address:0x12351131234 u64:6000 --profile [PROFILE]
The withdrawal request need to be approved from 2FA. In a test env, for getting signature of the second account(as a role of a server-side auth), you can use CLI options like --profile, --private-key, --private-key-file, --sender-account. Of course, in real Crossfader service, the only thing a user needs to do is SSO auth :D
This part is planned to be implemented.
For testing, deploy SampleDefi like Crossfader.
In contracts/sample-defi
,
aptos move create-resource-account-and-publish-package --seed 12333535 --address-name ra_addr --named-addresses origin_account=[YOUR_ACCOUNT_ADDRESS]
And then initialize it,
aptos move run --function-id 55790d1f3e8f4b0325f9d8b648952f982a95f2678706f500b4b18242b9c72d6a::sampledefi::init_coin_store --type-args 0x1::aptos_coin::AptosCoin
aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::stake --type-args 0x1::aptos_coin::AptosCoin --args u64:6000
aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::unstake --type-args 0x1::aptos_coin::AptosCoin --args u64:6000