전송 & Action
스마트 컨트랙트는 NEAR 전송 또는 다른 컨트랙트 호출과 같은 특정 Actions
를 수행할 수 있습니다.
Actions
의 중요한 속성은, 동일한 컨트랙트에서 작업할 때 일괄적으로 처리될 수 있다는 것입니다. Batched actions act as a unit: they execute in the same receipt, and if any fails, then they all get reverted.
정보
Actions
는 동일한 컨트랙트에 따라 행동하는 경우에만 일괄 처리될 수 있습니다. 컨트랙트에서 두 메서드를 일괄적으로 호출할 수 있지만, 서로 다른 컨트랙트에서 두 메서드를 일괄적으로 호출 할 수는 없습니다.
NEAR Ⓝ 전송
컨트랙트에서 $NEAR를 네트워크의 다른 계정으로 보낼 수 있습니다. $NEAR 전송에 대한 가스 비용은 고정되어 있으며, 프로토콜의 기본 구성을 기반으로 합니다. 현재 비용은 ~0.45 TGas
입니다.
- 🌐 JavaScript
- 🦀 Rust
import { NearBindgen, NearPromise, call } from 'near-sdk-js'
import { AccountId } from 'near-sdk-js/lib/types'
@NearBindgen({})
class Contract{
@call({})
transfer({ to, amount }: { to: AccountId, amount: bigint }) {
NearPromise.new(to).transfer(amount);
}
}
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::{near_bindgen, AccountId, Promise, Balance};
#[near_bindgen]
#[derive(Default, BorshDeserialize, BorshSerialize)]
pub struct Contract { }
#[near_bindgen]
impl Contract {
pub fn transfer(&self, to: AccountId, amount: Balance){
Promise::new(to).transfer(amount);
}
}
팁
전송이 실패하는 유일한 경우는 수신자 계정이 존재 하지 않는 경우입니다 .
주의
주의
당신의 잔고가 컨트랙트 스토리지를 충당하는 데 사용된다는 점을 기억하세요. 돈을 보낼 때 항상 향후 스토리지 요구 사항을 만족할 수 있도록 충분한 금액을 남겨 두시기 바랍니다.