Giter Site home page Giter Site logo

xraylarac / aptos-red-packet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from coming-chat/aptos-red-packet

0.0 0.0 0.0 79 KB

A red packet social application that combines the privacy chat on ComingChat and the omnichain wallet on ComingChat.

License: Apache License 2.0

Move 100.00%

aptos-red-packet's Introduction

Aptos Red Packet

Red packets implemented using the Move programming language

A red packet social application that combines the privacy chat on ComingChat and the omnichain wallet on ComingChat.

The code contract will be deployed to the Aptos smart contract platform

Supported dependencies

  • aptos-cli: Aptos CLI Release v1.0.0
  • AptosFramework: main @ 01108a2345b87d539d54a67b32db55193f9ace40
  • AptosStdlib: main @ 01108a2345b87d539d54a67b32db55193f9ace40

Roles and Calls

  • owner: publish, initialize, set_admin, set_fee_point
  • admin: register_coin, open, close, batch_close, set_base_prepaid_fee
  • user: create

Install

# aptos-cli
Install Aptos CLI
https://aptos.dev/cli-tools/aptos-cli-tool/install-aptos-cli

# red-packet
git clone https://github.com/coming-chat/red-packet.git
cd red-packet

# aptos-core
git clone https://github.com/aptos-labs/aptos-core.git
cd aptos-core
git checkout a5ac706f74c3b5088649e744b76ec6ed32635c0d

# red-packet tree

├── aptos-core
├── build
├── LICENSE
├── Move.toml
├── README.md
└── sources

Compile & Test & Publish

run aptos init in red-packet to config aptos network environment

example result

 cd red-packet
 cat .aptos/config.yaml 
---
profiles:
  default:
    private_key: <your privkey>
    public_key: <your pubkey>
    account: <your address>
    rest_url: "https://fullnode.devnet.aptoslabs.com/v1"
    faucet_url: "https://faucet.devnet.aptoslabs.com/"
aptos move compile --named-addresses RedPacket=<your address>

aptos move test

aptos move publish --named-addresses RedPacket=<your address>

bench data

create(after 150,000 items): 445~725 gas
open(max=1000 items): 64544 gas
batch_close(10000 items): 464853 gas

test cmds

test coins

module mycoin::Coins {
    /// Coin define
    ////////////////////////
    struct TestCoin {}

    struct XBTC {}

    struct XETH {}

    struct XDOT {}
    ////////////////////////
}
# publish mycoin
aptos move publish \
    --named-addresses mycoin=0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0

# issue coins
aptos move run \
    --function-id 0x1::managed_coin::initialize \
    --args string:"Test" string:"Test" u8:8 bool:true \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::TestCoin \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::initialize \
    --args string:"XBTC" string:"XBTC" u8:8 bool:true \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XBTC \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::initialize \
    --args string:"XETH" string:"XETH" u8:8 bool:true \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XETH \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::initialize \
    --args string:"XDOT" string:"XDOT" u8:8 bool:true \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XDOT \
    --assume-yes

# register account
aptos move run \
    --function-id 0x1::managed_coin::register \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::TestCoin \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::register \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XBTC \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::register \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XETH \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::register \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XDOT \
    --assume-yes

# mint coins
aptos move run \
    --function-id 0x1::managed_coin::mint \
    --args address:0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0 u64:10000000000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::TestCoin \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::mint \
    --args address:0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0 u64:10000000000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XBTC \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::mint \
    --args address:0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0 u64:10000000000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XETH \
    --assume-yes

aptos move run \
    --function-id 0x1::managed_coin::mint \
    --args address:0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0 u64:10000000000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XDOT \
    --assume-yes

==================================================================================================

# publish red-packet
aptos move publish --named-addresses RedPacket=0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0

# owner red_packet::initialize
aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::initialize \
    --args address:0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0 \
           address:0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0

# admin red_packet::register_coin
aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::register_coin \
    --type-args 0x1::aptos_coin::AptosCoin \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::register_coin \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XBTC \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::register_coin \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XETH \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::register_coin \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XDOT \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::register_coin \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::TestCoin \
    --assume-yes

# admin red_packet::create
aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::create \
    --args u64:0 u64:1000 u64:10000 \
    --type-args 0x1::aptos_coin::AptosCoin \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::create \
    --args u64:1 u64:1000 u64:10000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XBTC \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::create \
    --args u64:2 u64:1000 u64:10000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XETH \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::create \
    --args u64:3 u64:1000 u64:10000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::XDOT \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::create \
    --args u64:4 u64:1000 u64:10000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::TestCoin \
    --assume-yes


# bench (needs create2)
aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::create2 \
    --args u64:0 u64:1000 u64:10000 u64:50000 \
    --type-args 0x1::aptos_coin::AptosCoin \
    --max-gas 4000000 \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::create2 \
    --args u64:4 u64:1000 u64:10000 u64:50000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::TestCoin \
    --max-gas 4000000 \
    --assume-yes

aptos move run \
    --function-id 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::red_packet::batch_close \
    --args u64:4 u64:0 u64:10000 \
    --type-args 0xa24881e004fdbc5550932bb2879129351c21432f21f32d94bf11603bebd9f5c0::Coins::TestCoin \
    --max-gas 4000000 \
    --assume-yes

aptos-red-packet's People

Contributors

icodezjb avatar gguoss avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.