Skip to content

Commit

Permalink
add entry and view function examples (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan authored Jul 15, 2024
1 parent f2083da commit 337154a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { InputTransactionData } from "@aptos-labs/wallet-adapter-react";

export type TransferAPTArguments = {
to: string; // the account address to transfer the APT to
amount: number; // the APT amount to transfer
};

export const trasnferAPT = (args: TransferAPTArguments): InputTransactionData => {
const { to, amount } = args;
return {
data: {
function: "0x1::aptos_account::transfer",
functionArguments: [to, amount],
},
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { aptosClient } from "@/utils/aptosClient";

export type AccountAPTBalanceArguments = {
accountAddress: string;
};

export const accountAPTBalance = async (args: AccountAPTBalanceArguments): Promise<number> => {
const { accountAddress } = args;
const balance = await aptosClient().view<[number]>({
payload: {
function: "0x1::coin::balance",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
functionArguments: [accountAddress],
},
});
return balance[0];
};

0 comments on commit 337154a

Please sign in to comment.