인게임 통화
Sui Closed-Loop Token standard를 사용하면 in-game currency를 생성할 수 있다. 이는 플레이어의 행동에 대해 지급하거나 구매할 수 있게 만들 수 있는 gems나 diamonds 같은 in-game 자산 형태일 수 있다. 이 currency는 Sui에서 민트하지만, 플레이어는 게임 자체의 경제 안에서만 사용할 수 있다. 일반적으로 희소성과 게임 경제를 유지하기 위해 미리 정한 수량으로 민트한다.
이 예시는 Move로 governance-controlled currency를 구현한다. Currency를 transfer하려면 approval이 필요하며, 이는 커스텀 규칙 logic으로 구현된다. 이 예시의 currency는 King Credits이며, Crown Council의 approval이 있어야만 전송할 수 있다.
Currency 초기화
King Credits currency를 만들려면 coin_registry::new_currency_with_otw 모듈을 사용해 currency를 초기화하고 token::add_rule_for_action으로 currency 정책을 구성한다:
I3/king_credits/sources/king_credits.move. You probably need to run `pnpm prebuild` and restart the site.init 함수는 패키지 publish event 중에만 실행된다.
Custom transfer 규칙 설정
다른 Move 패키지에서 add_rule_config 함수를 구현해 초기 council members로 규칙 configuration을 초기화하고, members 최대 수에 제한을 설정하며, 그 수가 최대값을 초과하지 않는지 확인하는 check를 포함한다.
add_council_member와 remove_council_member 함수는 council members를 추가하고 제거한다. prove 함수는 요청 송신자가 council member인지 확인하고, 맞다면 규칙에 approval을 추가한다:
I3/king_credits/sources/crown_council_rule.move. You probably need to run `pnpm prebuild` and restart the site.