이 함수들은 Solana 및 SVM 호환 블록체인을 위한 SVM 애드온을 사용할 때 사용할 수 있습니다.
system_program_id
svm::system_program_id는 System Program의 ID인
11111111111111111111111111111111를 반환합니다.
output "system_program_id" {value = svm::system_program_id()}// > 11111111111111111111111111111111
default_pubkey
svm::default_pubkey는 기본 pubkey인 11111111111111111111111111111111를
반환합니다.
output "default_pubkey" {value = svm::default_pubkey()}// > 11111111111111111111111111111111
get_instruction_data_from_idl_path
svm::get_instruction_data_from_idl_path는 제공된 IDL 파일을 기반으로 타입 검사
및 직렬화를 제공하며, 프로그램 호출을 위한 인코딩된 instruction data를
생성합니다.
입력값
| Name | Required | Type | Description |
|---|---|---|---|
idl_path | required | string | txtx.yml 기준 IDL .json 파일의 상대 경로 |
instruction_name | required | string | 데이터를 생성할 instruction의 이름 |
arguments | optional | array[string] | 데이터를 생성할 instruction 인수 |
output "data" {value = svm::get_instruction_data_from_idl("/path/to/idl.json", "my_instruction", ["arg1", "arg2"])}// > data: 0x95763bdcc47fa1b305000000776f726c64
get_instruction_data_from_idl
svm::get_instruction_data_from_idl는 제공된 IDL 데이터를 기반으로 타입 검사 및
직렬화를 제공하며, 프로그램 호출을 위한 인코딩된 instruction data를 생성합니다.
입력값
| Name | Required | Type | Description |
|---|---|---|---|
idl | required | string | SVM_IDL | 프로그램 IDL |
instruction_name | required | string | IDL에서 인덱싱된 대로 데이터를 생성할 instruction의 이름 |
arguments | optional | array[string] | 데이터를 생성할 instruction 인수 |
output "data" {value = svm::get_instruction_data_from_idl(variable.contract.idl, "my_instruction", ["arg1", "arg2"])}// > data: 0x95763bdcc47fa1b305000000776f726c64
get_program_from_anchor_project
svm::get_program_from_anchor_project는 Anchor 프로젝트 내 프로그램의 배포
아티팩트를 가져옵니다.
입력값
| 이름 | 필수 여부 | 타입 | 설명 |
|---|---|---|---|
program_name | 필수 | string | 배포할 프로그램의 이름 |
keypair_path | 선택 | string | 프로그램 keypair 파일의 경로 |
idl_path | 선택 | string | 프로그램 IDL 파일의 경로 |
bin_path | 선택 | string | 프로그램 바이너리 파일의 경로 |
variable "contract" {value = svm::get_program_from_anchor_project("my_program")}output "idl" {value = variable.contract.idl}
get_program_from_native_project
svm::get_program_from_native_project는 Anchor를 사용하지 않는 프로그램의 배포
아티팩트를 가져옵니다.
입력값
| 이름 | 필수 여부 | 타입 | 설명 |
|---|---|---|---|
program_name | 필수 | string | 배포할 프로그램의 이름 |
keypair_path | 선택 | string | 프로그램 keypair 파일의 경로 |
idl_path | 선택 | string | 프로그램 IDL 파일의 경로 |
bin_path | 선택 | string | 프로그램 바이너리 파일의 경로 |
variable "contract" {value = svm::get_program_from_native_project("my_program")}output "idl" {value = variable.contract.idl}
sol_to_lamports
svm::sol_to_lamports는 입력된 SOL 금액을 lamport로 변환합니다.
output "lamports" {value = svm::sol_to_lamports(1.1)}// lamports: 1100000000
lamports_to_sol
svm::lamports_to_sol는 입력된 lamport 금액을 SOL로 변환합니다.
output "sol" {value = svm::lamports_to_sol(1100000000)}// sol: 1.1
find_pda
svm::find_pda는 제공된 프로그램 ID와 시드를 사용하여 유효한 PDA를 찾습니다.
입력값
| 이름 | 필수 여부 | 타입 | 설명 |
|---|---|---|---|
program_id | 필수 | string | PDA가 파생된 프로그램의 주소 |
seeds | 선택 | array[string] | 시드의 선택적 배열 (최대 16개, 각 32바이트) |
variable "pda" {value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", ["data"])}output "pda" {value = std::encode_base58(variable.pda.pda)}output "bump" {value = variable.pda.bump_seed}// > pda: 4amHoWMBgLkPfM8Nq9ZP33Liq9FCuqrLoU1feejkdsUJ// > bump: 252
get_associated_token_account
svm::get_associated_token_account는 제공된 지갑 및 토큰 민트 주소에 대한
associated token account의 주소를 계산합니다.
입력
| Name | Required | Type | Description |
|---|---|---|---|
wallet_address | required | string | 지갑의 주소 |
token_mint_address | optional | string | 토큰 민트의 주소 |
variable "token_account" {value = svm::get_associated_token_account(signer.caller.address, "So11111111111111111111111111111111111111112")}
create_token_account_instruction
svm::create_token_account_instruction는 associated token account를 생성하기
위한 원시 명령어 바이트를 생성합니다.
입력
| Name | Required | Type | Description |
|---|---|---|---|
funding_address | required | string | 자금 지원 계정의 주소 |
wallet_address | required | string | 지갑의 주소 |
token_mint_address | optional | string | 토큰 민트의 주소 |
token_program_id | optional | string | token program의 주소 |
action "call" "svm::process_instructions" {signers = [signer.caller]instruction {raw_bytes = svm::create_token_account_instruction(signer.caller.address, // funding addresssigner.caller.address, // wallet addressvariable.token_mint, // token mint addressvariable.token_program // token program id)}}
u64
svm::u64는 PDA 파생에서 seed로 사용하기에 적합한 u64 정수의 바이트 배열 표현을
생성합니다.
입력
| Name | Required | Type | Description |
|---|---|---|---|
value | required | integer | 바이트 배열로 변환할 u64 정수 |
variable "pda" {value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", [svm::u64(1000000000)])}
i64
svm::i64는 PDA 파생에서 seed로 사용하기에 적합한 i64 정수의 바이트 배열 표현을
생성합니다.
입력
| Name | Required | Type | Description |
|---|---|---|---|
value | required | integer | 바이트 배열로 변환할 i64 정수 |
variable "pda" {value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", [svm::i64(-1000000000)])}
Is this page helpful?