Ephemeral accounts 는 Ephemeral Rollup 안에만 존재하는 계정입니다. sponsor 계정(ER에 위임된 계정)이 32 lamports/byte 의 비용으로 ephemeral accounts 의 rent를 대신 지불합니다. 이는 Solana 기본 rent보다 약 109배 저렴합니다. 주요 특징:Documentation Index
Fetch the complete documentation index at: https://docs.magicblock.gg/llms.txt
Use this file to discover all available pages before exploring further.
- 생성부터 종료까지 완전히 ER 안에서 이루어짐
- 호출한 프로그램이 소유함(CPI 컨텍스트에서 추론)
- sponsor 계정의 lamports로 자금 조달됨
- 생성, 리사이즈, 종료 가능
#[ephemeral_accounts] Macro
이 proc-macro attribute는 Anchor Accounts struct에 붙입니다. #[account(...)] 안의 두 가지 커스텀 마커를 인식합니다.
| 마커 | 목적 |
|---|---|
sponsor | ephemeral accounts 의 rent를 지불하는 계정을 표시 |
eph | 계정을 ephemeral(ER 전용)로 표시 |
검증 규칙
eph필드가 하나라도 있으면 최소 하나의sponsor가 필요- 각 struct 당 허용되는
sponsor는 하나뿐 eph는init또는init_if_needed와 함께 사용할 수 없음(대신 생성된 메서드 사용)- sponsor가 PDA(
Signer가 아님)인 경우 PDA 서명을 위한seeds가 필요
생성되는 메서드
conversation 이라는 필드 이름에 대해 macro는 다음을 생성합니다.
| 메서드 | 시그니처 | 설명 |
|---|---|---|
create_ephemeral_conversation | (data_len: u32) -> Result<()> | ephemeral account 생성 |
init_if_needed_ephemeral_conversation | (data_len: u32) -> Result<()> | data_len == 0 일 때만 생성 |
resize_ephemeral_conversation | (new_data_len: u32) -> Result<()> | 계정 크기 확장 또는 축소 |
close_ephemeral_conversation | () -> Result<()> | 계정을 닫고 rent를 sponsor에게 환불 |
서명 요구사항
- Sponsor: 모든 작업(create, resize, close)에서 signer여야 함
- Ephemeral: create 시에만 signer여야 함(pubkey squatting 방지). resize나 close에는 필요 없음.
- PDA 계정의 경우 macro가
find_program_address로 signer seeds를 자동 유도함
Rent 모델
- 확장: sponsor가 추가 rent를 vault에 지불
- 축소: vault가 초과 rent를 sponsor에게 환불
- 종료: 모든 rent가 vault에서 sponsor에게 환불
Ephemeral Account 생성하기
Ephemeral Account 리사이즈하기
Ephemeral Account 종료하기
Wallet을 Sponsor로 사용하기
PDA 대신Signer 를 sponsor로 직접 사용할 수도 있습니다.
TypeScript 클라이언트 사용법
ephemeral account 관련 모든 작업은 base layer가 아니라 ER connection 으로 전송됩니다.자주 걸리는 함정
eph fields must use AccountInfo, not Account
eph fields must use AccountInfo, not Account
eph fields must use AccountInfo<'info>, not Account<'info, T>. The account doesn’t exist yet at validation time, so Anchor cannot deserialize it.Manual serialization is required after create
Manual serialization is required after create
After calling
create_ephemeral_*, you must serialize your data struct into the raw account data yourself. The macro allocates space but does not write any data.Cannot combine eph with init
Cannot combine eph with init
The macro enforces this at compile time. Use the generated
create_ephemeral_* method instead of Anchor’s init constraint.Sponsor must be delegated first
Sponsor must be delegated first
The sponsor account needs lamports on the ER to pay ephemeral rent. It must be delegated before creating ephemeral accounts.
Top up the sponsor before delegation
Top up the sponsor before delegation
Transfer extra SOL to the sponsor account before delegating it, so it has enough lamports to fund ephemeral accounts on the ER.
vault and magic_program are auto-injected
vault and magic_program are auto-injected
You don’t need to declare them in your struct, but they appear in the IDL and must be passed from the client. Anchor resolves them automatically if named correctly.
Learn More
Ephemeral Accounts Demo
Full example program on GitHub
Delegation & Undelegation
How delegation and state synchronization work
Quickstart
Build your first program with Ephemeral Rollups

