Contract 8ae1550db6f33311e473c1e853d192dd72623cc02c993608a86382469473fa91

← Back to Index 📥 Download WASM

Meta

home_domain stellarcarbon.io
rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.91.1
source_repo stellarcarbon/sorocarbon

Instances

  • CCJTPZVVYSHDFTJV23GXXCAGDIIA2GCC36T35L6WMB4VT3NR4R6NRHLG

Interface

Activates the contract, allowing sink operations. Requires admin authorization and extends the instance TTL.

Arguments

  • env - The Soroban environment.
fn activate(env: soroban_sdk::Env)

Checks if the contract is currently active. A deactivated contract that does not have a successor may be temporarily paused. Extends the instance TTL before returning the value.

Arguments

  • env - The Soroban environment.

Returns

A boolean indicating if the contract is active.

fn is_active(env: soroban_sdk::Env) -> bool

Deactivates the contract, preventing sink operations. Requires admin authorization and extends the instance TTL.

Arguments

  • env - The Soroban environment.
fn deactivate(env: soroban_sdk::Env)

Resets the CarbonSINK SAC admin by setting it to the current contract admin and deactivates the contract. This is called as part of the upgrade process, before setting a new SinkContract as the CarbonSINK SAC admin. Requires admin authorization and extends the instance TTL.

Arguments

  • env - The Soroban environment.

Returns

The address of the admin.

fn reset_admin(env: soroban_sdk::Env) -> soroban_sdk::Address

Sinks CARBON tokens by burning them from the funder and minting equivalent CarbonSINK tokens to the recipient. Quantizes the amount to kg resolution, checks minimum requirements, and handles authorization for CarbonSINK minting. Emits an event if the Mercury feature is enabled, otherwise performs the full sink operation.

Arguments

  • env - The Soroban environment.
  • funder - The address funding the sink operation (spends CARBON).
  • recipient - The address receiving the CarbonSINK tokens.
  • amount - The amount of CARBON to sink in decigrams.
  • project_id - The impact project ID (e.g. VCS1360).
  • memo_text - A retirement reason or transaction reference.

Returns

A Result indicating success (unit type) or a SinkError.

Errors

  • AmountTooLow - The quantized amount is below the minimum sink amount.
  • InsufficientBalance - The funder's CARBON balance is insufficient.
  • AccountOrTrustlineMissing - The funder or recipient has a missing trustline or account.
  • `TrustlineLimitReached
fn sink_carbon(
    env: soroban_sdk::Env,
    funder: soroban_sdk::Address,
    recipient: soroban_sdk::Address,
    amount: i64,
    project_id: soroban_sdk::Symbol,
    memo_text: soroban_sdk::String,
) -> Result<(), SinkError>

Initializes the SinkContract with the admin, CARBON asset ID, and CarbonSINK asset ID. Sets up initial storage values including admin, asset IDs, active status, and minimum sink amount. This constructor must be called once during contract deployment.

Arguments

  • env - The Soroban environment.
  • admin - The address of the contract administrator.
  • carbon_id - The address of the CARBON asset contract.
  • carbonsink_id - The address of the CarbonSINK asset contract.
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    carbon_id: soroban_sdk::Address,
    carbonsink_id: soroban_sdk::Address,
)

Retrieves the contract successor address, or the current contract address if no successor is set. Note that the successor contract may itself already be superseded by another contract. To find the latest active contract, call this function on each successor until it returns its own address. Extends the instance TTL before returning the value.

Arguments

  • env - The Soroban environment.

Returns

The successor address or the current contract address.

fn get_contract_successor(env: soroban_sdk::Env) -> soroban_sdk::Address

Sets the contract successor address for upgrades. Requires admin authorization and extends the instance TTL.

Arguments

  • env - The Soroban environment.
  • successor - The address of the successor contract.
fn set_contract_successor(env: soroban_sdk::Env, successor: soroban_sdk::Address)

Retrieves the minimum sink amount required for a sink operation. Extends the instance TTL before returning the value.

Arguments

  • env - The Soroban environment.

Returns

The minimum sink amount as an i64.

fn get_minimum_sink_amount(env: soroban_sdk::Env) -> i64

Sets the minimum sink amount for sink operations. Requires admin authorization, validates the amount is non-negative, and extends the instance TTL.

Arguments

  • env - The Soroban environment.
  • amount - The new minimum sink amount (must be >= 0).

Returns

A Result indicating success or an error if the amount is negative.

Errors

  • NegativeAmount - The provided amount must be positive.
fn set_minimum_sink_amount(env: soroban_sdk::Env, amount: i64) -> Result<(), SinkError>

Imports

WebAssembly Text (WAT) ▶