본문으로 건너뛰기

계정

NEAR 계정과 상호 작용, 생성 또는 삭제할 수 있습니다.

계정 불러오기

다음과 같은 명령을 통해 상호작용할 계정 객체를 반환합니다.

const account = await nearConnection.account("example-account.testnet");

Class Account

계정 생성

// create a new account using funds from the account used to create it. const account = await nearConnection.account("example-account.testnet");
await account.createAccount(
"example-account2.testnet", // new account name
"8hSHprDq2StXwMtNd43wDTXQYsjXcD4MJTXQYsjXcc", // public key for new account
"10000000000000000000" // initial balance for new account in yoctoNEAR
);

Account.createAccount 메서드

계정 삭제

// deletes account found in the `account` object
// transfers remaining account balance to the accountId passed as an argument
const account = await nearConnection.account("example-account.testnet");
await account.deleteAccount("beneficiary-account.testnet");

Account.deleteAccount 메서드

계정 잔고 가져오기

// gets account balance
const account = await nearConnection.account("example-account.testnet");
await account.getAccountBalance();

Account.getAccountBalance 메서드

계정 세부 정보 가져오기

승인된 앱과 같은 계정에 대한 정보를 반환합니다.

// gets account details in terms of authorized apps and transactions
const account = await nearConnection.account("example-account.testnet");
await account.getAccountDetails();

Account.getAccountDetails 메서드

컨트랙트 배포

컴파일된 WASM 파일에서 컨트랙트를 배포할 수 있습니다. 트랜잭션 및 Receipt 결과와 상태가 있는 객체를 반환합니다.

const account = await nearConnection.account("example-account.testnet");
const transactionOutcome = await account.deployContract(
fs.readFileSync("example-file.wasm")
);

Method Account.deployContract     Interface FinalExecutionOutcome

토큰 전송

계정 간에 NEAR 토큰을 전송합니다. 트랜잭션 및 Receipt 결과와 상태가 있는 객체를 반환합니다.

const account = await nearConnection.account("sender-account.testnet");
await account.sendMoney(
"receiver-account.testnet", // receiver account
"1000000000000000000000000" // amount in yoctoNEAR
);

Method Account.sendMoney     Interface FinalExecutionOutcome

상태

계정이 보유한 토큰의 양 또는 사용하는 스토리지의 양과 같은 기본 계정 정보를 가져옵니다.

const account = await nearConnection.account("example-account.testnet");
const accountState = await account.state();

Method Account.state     Interface AccountView

액세스 키

계정의 키를 가져오고 관리할 수 있습니다.

전체 액세스 키

// takes public key as string for argument
const account = await nearConnection.account("example-account.testnet");
await account.addKey("8hSHprDq2StXwMtNd43wDTXQYsjXcD4MJTXQYsjXcc");

Account.addKey 메서드

함수 액세스 키

const account = await nearConnection.account("example-account.testnet");
await account.addKey(
"8hSHprDq2StXwMtNd43wDTXQYsjXcD4MJTXQYsjXcc", // public key for new account
"example-account.testnet", // contract this key is allowed to call (optional)
"example_method", // methods this key is allowed to call (optional)
"2500000000000" // allowance key can use to call methods (optional)
);

Account.addKey 메서드

모든 액세스 키 가져오기

const account = await nearConnection.account("example-account.testnet");
await account.getAccessKeys();

Method Account.getAccessKeys     Interface AccessKeyInfoView

액세스 키 삭제

const account = await nearConnection.account("example-account.testnet");
await account.deleteKey("8hSHprDq2StXwMtNd43wDTXQYsjXcD4MJTXQYsjXcc");

Account.deleteKey 메서드

Was this page helpful?