Skip to content

Commit 4b37fda

Browse files
authored
Guibescos/aptos example 2 (#327)
* Add example * Subfolder for my example * Ready to merge * Cleanup * Gitignore right * Renaming * Named address reset * Bump pyth-common-js * Cleanup * More cleanup * Cleanup * dev addresses * Link to addresses * Rename app * Add link * Fix * refactor * Renamed * Rename * Add import statement for Price * Update to pass vaa to get_update_fee * Update README * Rename directory * Comments * Add recency check * Format * Cleanup, remove bad practices * Better comments * Get rid of recency check * Update README
1 parent f77987d commit 4b37fda

24 files changed

+29300
-0
lines changed
File renamed without changes.

aptos/examples/mint_nft/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.aptos
2+
build

aptos/examples/mint_nft/Move.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "Examples"
3+
version = "0.0.0"
4+
upgrade_policy = "compatible"
5+
6+
[dependencies]
7+
AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "main" }
8+
AptosToken = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-token/", rev = "main" }
9+
Pyth = { git = "https://github.com/pyth-network/pyth-crosschain.git", subdir = "aptos/contracts", rev = "main" }
10+
11+
[addresses]
12+
# These are testnet addresses https://docs.pyth.network/consume-data/aptos#addresses
13+
aptos_framework = "0x1"
14+
mint_nft = "_"
15+
pyth = "0xaa706d631cde8c634fe1876b0c93e4dec69d0c6ccac30a734e9e257042e81541"
16+
deployer = "0xb138581594ebd7763cfa3c3e455050139b7304c6d41e7094a1c78da4e6761ed8"
17+
wormhole = "0x1b1752e26b65fc24971ee5ec9718d2ccdd36bf20486a10b2973ea6dedc6cd197"
18+
19+
[dev-addresses]
20+
mint_nft = "0xb138581594ebd7763cfa3c3e455050139b7304c6d41e7094a1c78da4e6761ed8"
21+
pyth = "0xe2f37b8ac45d29d5ea23eb7d16dd3f7a7ab6426f5a998d6c23ecd3ae8d9d29eb"
22+
deployer = "0x277fa055b6a73c42c0662d5236c65c864ccbf2d4abd21f174a30c8b786eab84b"
23+
wormhole = "0x251011524cd0f76881f16e7c2d822f0c1c9510bfd2430ba24e1b3d52796df204"

aptos/examples/mint_nft/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Example Full-Stack App: 100$ USD Mint
2+
3+
The goal of this contract is managing an NFT mint where the mint is paid in native currency but the cost of one NFT is always 100$.
4+
This example is intended to be run on Aptos testnet because it depends on Pyth and Wormhole existing onchain.
5+
6+
### Important files :
7+
- `./sources/minting.move` has the smart contract logic (the code that will run onchain)
8+
- `./app/src/App.tsx` has the React application. The core logic of how the frontend will interact with the wallet and the blockchain.
9+
Both combined contain the key pieces of code needed to make an Aptos fullstack app using Pyth!
10+
11+
### How to deploy the smart contract :
12+
13+
- Use `aptos init` with rest_url : `https://testnet.aptoslabs.com/` and faucet `https://faucet.testnet.aptoslabs.com` to generate a new keypair.
14+
- Use a faucet to airdrop testnet APT to your newly created account by calling `aptos account fund-with-faucet --account default`. If this doesn't work, I have had success importing my private key from `.aptos/config.yaml` into Petra and clicking the airdrop button. Otherwise send APT from another account.
15+
- Get your account address from `.aptos/config.yaml` and replace `mint_nft="_"` by `mint_nft="<ADDRESS>"` in `Move.toml`
16+
- `aptos move compile`
17+
- `aptos move publish`
18+
19+
### How to run the webapp :
20+
21+
- In `app/src/App.tsx` replace `const MINT_NFT_MODULE = "_"` by `const MINT_NFT_MODULE = "<ADDRESS>"` the address of your module from above.
22+
- `npm install`
23+
- `npm run start`
24+
- Go to `http://localhost:3000/` in your browser and use Petra wallet to transact with the app.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

0 commit comments

Comments
 (0)