Move Language Practice Repo

This project is test repository for Move Language. It's mimicking UniswapV2 style constant product AMM.

Installation

  • Install aptos-cli
    • You need a cargo and some other dependencies. See installation guides.
    • If you're interfacing with an aptos-core main branch, aptos-cli should also be a main branch (see related issue)
cargo install --git https://github.com/aptos-labs/aptos-core.git aptos --branch main
  • Install aptos-core
git clone https://github.com/aptos-labs/aptos-core.git
cd aptos-core
./scripts/dev_setup.sh
source ~/.cargo/env

How to test

  • Before you deploy a contract on aptos, check with move test
aptos move test

How to run

  1. Run local testnet
# run local testnet
aptos node run-local-testnet --with-faucet
  1. Configure your aptos CLI to use local testnet
  • Change rest_url and faucet_url to local of ./.aptos/config.yaml
    rest_url: "http://0.0.0.0:8080"
    faucet_url: "http://0.0.0.0:8081"
  • You can also use aptos init with following flags :
aptos init --profile local --rest-url http://localhost:8080 --faucet-url http://localhost:8081
  • Set private key with private_key in config.yaml
  1. Create and Fund to accounts
PROFILE=local

# fund account
aptos account fund-with-faucet --profile $PROFILE --account $PROFILE

# create resource account
aptos account create-resource-account --profile $PROFILE --seed 1
  1. Publish a Move module
aptos move publish --profile $PROFILE --package-dir /opt/git/aptos-core/aptos-move/move-examples/hello_blockchain --named-addresses AMMPractice=$PROFILE
  • For example :
# run in package directory, "/AMMPractice"
aptos move publish --profile $PROFILE --named-addresses AMMPractice=84c898acc8e07735e7c1a65738f2b8720d2b31ab6f9dc4244a8ae3158447fb2b

aptos move publish --named-addresses AMMPractice=84c898acc8e07735e7c1a65738f2b8720d2b31ab6f9dc4244a8ae3158447fb2b

  1. Set private key
  • Copy private_key from ./.aptos/config.yaml to ./examples/.env. For example :
# without 0x prefix
SEED="c31d55d9fd922e633e60b7be70d3aabf92eb881822607b7ec0451ae7d469d504"

. Run python test script

pip3 install -r requirements.txt
python3 ./main.py