Receiving Faucet

What is Faucet?

Faucet์ด๋ž€ ์ง์—ญํ•˜๋ฉด ์ˆ˜๋„๊ผญ์ง€๋ผ๋Š” ์˜๋ฏธ๋กœ ๋ธ”๋ก์ฒด์ธ ์ƒํƒœ๊ณ„์—์„œ๋Š” ํŠธ๋žœ์žญ์…˜์„ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด ์†Œ๋Ÿ‰์˜ Native Token์„ ์ง€์›๋ฐ›๋Š” ํ–‰์œ„๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. Aptos์—์„œ๋Š” Faucet ํ•œ ๋ฒˆ์— ์ตœ๋Œ€ 1 APT๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ์œผ๋ฉฐ Devnet์˜ ๊ฒฝ์šฐ IP๋‹น ํ•˜๋ฃจ 100ํšŒ, Testnet์˜ ๊ฒฝ์šฐ IP๋‹น ํ•˜๋ฃจ 10ํšŒ๋กœ ์ œํ•œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ“˜

์ด ํŠœํ† ๋ฆฌ์–ผ์„ ํ†ตํ•ด ์•„๋ž˜ ๋‚ด์šฉ์„ ๋ฐฐ์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

  • ์‚ฌ์šฉ์ž์˜ ๊ณ„์ •์— Faucet์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์‚ฌ์šฉ์ž์˜ ๊ณ„์ •์— ์žˆ๋Š” APT coin์˜ ์ž”๊ณ ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์ „์ฒด ํŠœํ† ๋ฆฌ์–ผ ์ฝ”๋“œ๋Š” ์•„๋ž˜ ๋งํฌ๋ฅผ ํ†ตํ•ด ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Get faucet using SDK

Step 1. ๋ณด์œ ํ•œ Account์˜ address๋ฅผ ์ด์šฉํ•˜์—ฌ Faucet์„ ๋ฐ›๊ณ  ์ž”๊ณ  ํ™•์ธํ•˜๊ธฐ

fundAccount ๋ฉ”์„œ๋“œ๋ฅผ ์ด์šฉํ•˜์—ฌ Account์— Faucet์„ ๋ฐ›๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ Account๊ฐ€ ์—†๋‹ค๋ฉด Nodit์—์„œ ์ œ๊ณตํ•˜๋Š” ํŠœํ† ๋ฆฌ์–ผ์„ ์ง„ํ–‰ํ•ด Account ์ƒ์„ฑ ๋ฐฉ๋ฒ•์„ ๋ฐฐ์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด ์ž‘์„ฑ ํ›„ ํ•ด๋‹น ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜์—ฌ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

// faucet.ts
import {
  Aptos,
  AptosConfig,
} from "@aptos-labs/ts-sdk";

const config = new AptosConfig({
  fullnode: "your_Nodit_Aptos_testnet_node_endpoint",
  indexer: "your_Nodit_Aptos_indexer_endpoint",
  faucet: "https://faucet.testnet.aptoslabs.com",
});
const aptos = new Aptos(config);
const address = "input_your_account_address";

(async (address : string) => {
  try {
    const getFaucet = await aptos.fundAccount({
      accountAddress: address,
      amount: 100_000_000,
    });
    console.log(getFaucet);
  } catch (error) {
    console.error(error);
  }
})(address);

$ ts-node faucet.ts

์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰์ด ๋˜์—ˆ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ํŠธ๋žœ์žญ์…˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

{
  version: '5448867634',
  hash: '0xf65552c190db9e4783a0de0f3e7410992f42dfe65d21973e229912bb662b1080',
  state_change_hash: '0xffc3432d6781ce8d08296563a87a4a52d640270a2372b663da45686c704e3730',
  event_root_hash: '0xafdb74074e9a021dff5e66edc00e608b9d47d55b609dec960234f5575a671dbc',
  state_checkpoint_hash: null,
  gas_used: '13',
  success: true,
  vm_status: 'Executed successfully',
  accumulator_root_hash: '0x28a0d5048cbeccae2c04941a3573bd6b2b226c7eb433e938b7d648694a6c91d3',
  changes: [
    {
      address: '0x1caef4f995a3d7f545d0d246562be15f73b8cace9dca0aea7e610afa947cb3a3',
      state_key_hash: '0xf8a1df6b644e81ee241ed29dbb82b456b897daef76239d37a8390ecf48ae881d',
      data: [Object],
      type: 'write_resource'
    },
...
    {
      state_key_hash: '0x6e4b28d40f98a106a65163530924c0dcb40c1349d3aa915d108b4d6cfc1ddb19',
      handle: '0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca',
      key: '0x0619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935',
      value: '0x30df2ed89f88a7940100000000000000',
      data: null,
      type: 'write_table_item'
    }
  ],
  sender: '0x1caef4f995a3d7f545d0d246562be15f73b8cace9dca0aea7e610afa947cb3a3',
  sequence_number: '1270787',
  max_gas_amount: '500000',
  gas_unit_price: '100',
  expiration_timestamp_secs: '1721120484',
  payload: {
    code: {
      bytecode: '0xa11ceb0b0500000008010008020804030c150421020523100733500883012006a30114000000010002000301050800030403010002060105010001070002000008000200010403060c050301050001060c01080001030d6170746f735f6163636f756e740a6170746f735f636f696e04636f696e067369676e65720a616464726573735f6f66094170746f73436f696e0762616c616e6365046d696e74087472616e7366657200000000000000000000000000000000000000000000000000000000000000010308a0860100000000000308ffffffffffffffff000001170a0011000c030a03380007010a02170700172304120a000b030a0207001611020b000b010b02110302',
      abi: [Object]
    },
    type_arguments: [],
    arguments: [
      '0x3a8e4a6d4e3d38329012d48f1703b62314070285ee85c06e5a1e29fcce7d8cab',
      '100000000'
    ],
    type: 'script_payload'
  },
  signature: {
    public_key: '0xdcefb58cbf71a655cc7f92f5f0a0d4023d1373f448ea0a69a57e7a303e75df6e',
    signature: '0x90ed08b1621ba2067d8c25c510a241672f34541aca4e9147d26bcf7061aab95239d47b5daba97a3e4292adb5d8be8dced2a8a363445659572c7982b06e02aa0b',
    type: 'ed25519_signature'
  },
  events: [
    {
      guid: [Object],
      sequence_number: '1270787',
      type: '0x1::coin::DepositEvent',
      data: [Object]
    },
...
    {
      guid: [Object],
      sequence_number: '0',
      type: '0x1::transaction_fee::FeeStatement',
      data: [Object]
    }
  ],
  timestamp: '1721120469466436',
  type: 'user_transaction'
}

๊ธฐ์กด์˜ ์ฝ”๋“œ์— getAccountAPTAmount ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ํ•ด๋‹น ๊ณ„์ •์˜ APT ์ž”๊ณ ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

import {
  Aptos,
  AptosConfig,
} from "@aptos-labs/ts-sdk";

const config = new AptosConfig({
  fullnode: "your_Nodit_Aptos_testnet_node_endpoint",
  indexer: "your_Nodit_Aptos_indexer_endpoint",
  faucet: "https://faucet.testnet.aptoslabs.com",
});
const aptos = new Aptos(config);
const address = "input_your_account_address";

(async (address : string) => {
  try {
    const getFaucet = await aptos.fundAccount({
      accountAddress: address,
      amount: 100_000_000,
    });
    console.log(getFaucet);

    const getBalance = await aptos.getAccountAPTAmount({
      accountAddress: address,
    });
    console.log("My APT Balance :", getBalance);
  } catch (error) {
    console.error(error);
  }
})(address);

My APT Balance : 100000000

Get faucet using Aptos faucet client

Step 2. ๋ณด์œ ํ•œ Account์˜ address๋ฅผ ์ด์šฉํ•˜์—ฌ Faucet ๋ฐ›๊ธฐ (aptos-faucet-client)

Aptos์—์„œ๋Š” Faucet์„ ์œ„ํ•œ ํด๋ผ์ด์–ธํŠธ๋ฅผ ๋ณ„๋„๋กœ ์ œ๊ณตํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•ด AptosFaucetClient ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•œ ํ›„ fund ๋ฉ”์„œ๋“œ๋ฅผ ์ด์šฉํ•˜์—ฌ faucet์„ ์š”์ฒญํ•ฉ๋‹ˆ๋‹ค.

import {
  AptosFaucetClient,
  FundRequest,
  FundResponse,
} from "@aptos-labs/aptos-faucet-client";

const faucetClient = new AptosFaucetClient({
BASE: "https://faucet.testnet.aptoslabs.com",
});
const address = "input_your_account_address";

(async (address : string) => {
  const request: FundRequest = {
    amount : 100_000_000,
    address,
  };
  const getFaucet = await faucetClient.fund.fund({ requestBody: request });
  console.log(getFaucet);
})(address);

ํ•ด๋‹น ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด txn_hashes ๋ผ๋Š” ์ด๋ฆ„์˜ ํ•„๋“œ์™€ ํŠธ๋žœ์žญ์…˜ ํ•ด์‹œ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

{
  txn_hashes: [
    '<Your_Transaction_Hash>'
  ],
  ...
}

Step 1์—์„œ ์ž‘์„ฑํ•œ APT ์ž”๊ณ  ํ™•์ธ ์ฝ”๋“œ๋ฅผ ์ด์šฉํ•˜์—ฌ faucet์„ ๋ฐ›์€ ํ›„ ์ž”๊ณ ๋ฅผ ํ™•์ธํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

import {
  AptosFaucetClient,
  FundRequest,
  FundResponse,
} from "@aptos-labs/aptos-faucet-client";

const faucetClient = new AptosFaucetClient({
BASE: "https://faucet.testnet.aptoslabs.com",
});

const address = "input_your_account_address"

(async (address : string) => {
  const request: FundRequest = {
    amount : 100_000_000,
		address,
  };
  const [getFaucet] = await faucetClient.fund.fund({ requestBody: request }).txn_hashes;
  console.log(getFaucet);
  
  const getBalance = await aptos.getAccountAPTAmount({
  accountAddress: address,
  });
  console.log("My APT Balance :", getBalance);
})(address);

fund ๋ฉ”์„œ๋“œ์˜ ์‘๋‹ต ๋ฐ˜ํ™˜ ์‹œ์ ์€ ๋„คํŠธ์›Œํฌ์—์„œ ํŠธ๋žœ์žญ์…˜์ด ์ฒ˜๋ฆฌ๋œ ์ดํ›„๊ฐ€ ์•„๋‹Œ ํŠธ๋žœ์žญ์…˜ ์‹คํ–‰ ์‹œ์ ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ์œ„์™€ ๊ฐ™์ด ์ž‘์„ฑ ํ›„ ์ž”๊ณ ๋ฅผ ํ™•์ธํ•  ๊ฒฝ์šฐ faucet์„ ๋ฐ›๊ธฐ ์ „ ๊ณ„์ •์ด ๋ณด์œ ํ•œ ์ž”๊ณ ๊ฐ€ ๋ฐ˜ํ™˜๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๋„คํŠธ์›Œํฌ์˜ ํŠธ๋žœ์žญ์…˜์ด ์ฒ˜๋ฆฌ ๋  ๋•Œ ๊นŒ์ง€ ๋Œ€๊ธฐํ•œ ํ›„ ์‘๋‹ต์„ ๋ฐ˜ํ™˜ํ•˜๋Š”waitForTransaction ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

//faucet.ts
import { Aptos, AptosConfig } from "@aptos-labs/ts-sdk";
import {
  AptosFaucetClient,
  FundRequest,
  FundResponse,
} from "@aptos-labs/aptos-faucet-client";

const config = new AptosConfig({
  fullnode: "your_Nodit_Aptos_testnet_node_endpoint",
  indexer: "your_Nodit_Aptos_indexer_endpoint",
});
const aptos = new Aptos(config);
const faucetClient = new AptosFaucetClient({
BASE: "https://faucet.testnet.aptoslabs.com",
});

const address = "your_account_address";

(async (address: string) => {
  try {
    const request: FundRequest = {
      amount: 100_000_000,
      address,
    };
    const [getFaucet] = (await faucetClient.fund.fund({ requestBody: request }))
      .txn_hashes;

    await aptos.waitForTransaction({
      transactionHash: getFaucet,
    });

    const getBalance = await aptos.getAccountAPTAmount({
      accountAddress: address,
    });
    console.log("My APT Balance :", getBalance);
  } catch (error) {
    console.error(error);
  }
})(address);

$ ts-node faucet.ts

faucet.ts ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋ฉด ํ„ฐ๋ฏธ๋„์—์„œ My APT Balance ์ž”๊ณ ๊ฐ€ ์ถ”๊ฐ€๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ๋ฐ›์€ APT๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‹ค๋ฅธ ์ฃผ์†Œ๋กœ APT๋ฅผ ์ „์†กํ•˜๊ฑฐ๋‚˜ ํŠธ๋žœ์žญ์…˜ ์‹คํ–‰ ์‹œ Gas Fee๋กœ ์ด์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

My APT Balance : 100000000
  • ํ™•์ธ์ด ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ์œ„์˜ ์ฝ”๋“œ์™€ ๋‹ค๋ฅธ ๋ถ€๋ถ„์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ด ๋ณด์„ธ์š”.
  • ์œ„์˜ ์ฝ”๋“œ์™€ ์ฐจ์ด๊ฐ€ ์—†๋Š”๋ฐ ๋˜์ง€ ์•Š๋‚˜์š”? ์—ฌ๊ธฐ[QnA ๋งํฌ]๋ฅผ ํด๋ฆญํ•˜์—ฌ QnA๋กœ ๋‚จ๊ฒจ์ฃผ์„ธ์š”!

๐Ÿ“˜

Aptos๋Š” ๋งค์šฐ ๋น ๋ฅด๊ฒŒ ์—…๋ฐ์ดํŠธ ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค!

Aptos ์žฌ๋‹จ์—์„œ ๋ฐฐํฌํ•œ SDK ๋ฒ„์ „์— ๋”ฐ๋ผ ๋ณ€๊ฒฝ๋˜๋Š” ์ ์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Nodit์€ ํ•ญ์ƒ ์ด๋ฅผ ํ™•์ธํ•˜๊ณ  ์žˆ์œผ๋‚˜ ์‹œ์ ์— ๋”ฐ๋ผ ์ฝ”๋“œ ๋ณ€๊ฒฝ์œผ๋กœ ์ธํ•œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.