Contract a890a551d8b8883e69fe90f826203e2d7a77f9247f75771395285e1229494677

← Back to Index 📥 Download WASM

Meta

rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.87.0

Instances

  • CB4WXHLU5VGRFYZUZ5BP372VZRPQIDNF24MZOANMJLUJYZHOBQYPAE4X

Interface

Initializes the contract with admin and reserve addresses

Arguments

  • env - The Soroban environment
  • admin - The address of the admin
  • reserve - The address of the reserve

Panics

  • If the contract is already initialized
fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    reserve: soroban_sdk::Address,
)

Gets the admin address

Arguments

  • env - The Soroban environment

Returns

  • The admin address

Panics

  • If admin is not initialized
fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address

Gets the reserve address

Arguments

  • env - The Soroban environment

Returns

  • The reserve address

Panics

  • If reserve is not initialized
fn get_reserve(env: soroban_sdk::Env) -> soroban_sdk::Address

Gets the protocol default fee

Arguments

  • env - The Soroban environment

Returns

  • The fee percentage (in basis points)
fn get_subs_fee(env: soroban_sdk::Env) -> u32

Updates the protocol fee

Arguments

  • env - The Soroban environment
  • fee - The new fee percentage (in basis points)

Panics

  • If the caller is not the admin
fn update_fee(env: soroban_sdk::Env, fee: u32)

Updates the reserve address

Arguments

  • env - The Soroban environment
  • reserve - The new reserve address

Panics

  • If the caller is not the admin
fn update_reserve(env: soroban_sdk::Env, reserve: soroban_sdk::Address)

Updates the app fee for a specific app

Arguments

  • env - The Soroban environment
  • caller - The address of the caller
  • app_id - The ID of the app
  • fee - The new fee percentage (in basis points)

Panics

  • If the caller is not authorized
fn update_app_fees(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    app_id: u64,
    fee: u64,
)

Gets the total number of apps

Arguments

  • env - The Soroban environment

Returns

  • The total number of apps
fn total_apps(env: soroban_sdk::Env) -> u64

Gets a specific app by ID

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app to get

Returns

  • Option containing the app if found, None otherwise
fn get_app(env: soroban_sdk::Env, app_id: u64) -> Option

Gets the fee for a specific app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app

Returns

  • The app's fee percentage (in basis points)
fn get_app_fee(env: soroban_sdk::Env, app_id: u64) -> u64

Gets the owner of a specific app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app

Returns

  • Option containing the owner address if found, None otherwise
fn get_app_owner(env: soroban_sdk::Env, app_id: u64) -> Option

Gets all apps owned by a user

Arguments

  • env - The Soroban environment
  • user - The address of the user

Returns

  • Option containing a vector of app IDs if found, None otherwise
fn get_user_apps(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> Option>

Gets the number of apps owned by an address

Arguments

  • env - The Soroban environment
  • owner - The address of the owner

Returns

  • The number of apps owned
fn get_owner_app_count(env: soroban_sdk::Env, owner: soroban_sdk::Address) -> u64

Gets a specific payment for an app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app
  • payment_id - The ID of the payment

Returns

  • Option containing the payment if found, None otherwise
fn get_app_payment(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
) -> Option

Gets all payments for an app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app

Returns

  • Option containing a vector of payment IDs if found, None otherwise
fn get_app_payments(
    env: soroban_sdk::Env,
    app_id: u64,
) -> Option>>

Gets a specific subscription

Arguments

  • env - The Soroban environment
  • subs_id - The ID of the subscription

Returns

  • Option containing the subscription if found, None otherwise
fn get_subscription(
    env: soroban_sdk::Env,
    subs_id: soroban_sdk::BytesN<32>,
) -> Option

Gets all subscriptions for a user

Arguments

  • env - The Soroban environment
  • user - The address of the user

Returns

  • Option containing a vector of subscription IDs if found, None otherwise
fn get_user_subscriptions(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> Option>>

Gets all subscribers for a specific payment in an app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app
  • payment_id - The ID of the payment

Returns

  • Option containing a vector of subscriber addresses if found, None otherwise
fn get_app_subscribers(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
) -> Option>

Gets all subscriptions for an app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app

Returns

  • Option containing a vector of subscription IDs if found, None otherwise
fn get_app_subscriptions(
    env: soroban_sdk::Env,
    app_id: u64,
) -> Option>>

Checks if a subscription is canceled

Arguments

  • env - The Soroban environment
  • subs_id - The ID of the subscription

Returns

  • True if the subscription is canceled, false otherwise
fn get_cancel_subscription(
    env: soroban_sdk::Env,
    subs_id: soroban_sdk::BytesN<32>,
) -> bool

Checks if a user has already used their trial period for an app

Arguments

  • env - The Soroban environment
  • user - The address of the user
  • app_id - The ID of the app

Returns

  • True if the user has used their trial, false otherwise
fn get_already_trial_subscribed(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    app_id: u64,
) -> bool

Gets a specific one-time payment

Arguments

  • env - The Soroban environment
  • otp_id - The ID of the one-time payment

Returns

  • Option containing the one-time payment if found, None otherwise
fn get_one_time_payment(
    env: soroban_sdk::Env,
    otp_id: soroban_sdk::BytesN<32>,
) -> Option

Gets all users who have made a specific one-time payment

Arguments

  • env - The Soroban environment
  • payment_id - The ID of the payment

Returns

  • Option containing a vector of user addresses if found, None otherwise
fn get_one_time_payment_users(
    env: soroban_sdk::Env,
    payment_id: soroban_sdk::BytesN<32>,
) -> Option>

Checks if a user is already subscribed to a payment

Arguments

  • env - The Soroban environment
  • user - The address of the user
  • app_id - The ID of the app
  • payment_id - The ID of the payment

Returns

  • True if the user is subscribed, false otherwise
fn get_already_subscribed(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
) -> bool

Creates a new app with the specified name and payments

Arguments

  • env - The Soroban environment
  • name - The name of the app
  • payments - Vector of payment configurations
  • creatoraddress - The address of the app creator

Returns

  • The ID of the newly created app

Panics

  • If the payments vector is empty
  • If a payment with the same name already exists
fn createapp(
    env: soroban_sdk::Env,
    name: soroban_sdk::BytesN<32>,
    payments: soroban_sdk::Vec,
    creatoraddress: soroban_sdk::Address,
) -> u64
fn add_payment(env: soroban_sdk::Env, app_id: u64, payments: soroban_sdk::Vec)

Gets the allowance for a user's tokens

Arguments

  • env - The Soroban environment
  • user - The address of the user
  • tokenaddress - The address of the token contract

Returns

  • The amount of tokens allowed
fn get_allowance(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    tokenaddress: soroban_sdk::Address,
) -> i128

Calculates the required amount for a subscription

Arguments

  • env - The Soroban environment
  • subscription_id - The ID of the subscription

Returns

  • The amount required for the subscription

Panics

  • If the subscription is not found
fn require_amount(
    env: soroban_sdk::Env,
    subscription_id: soroban_sdk::BytesN<32>,
) -> i128

Computes the required amount for a token payment

Arguments

  • env - The Soroban environment
  • token - The address of the token
  • limit_period - The limit period for the payment
  • token_price - The price of the token
  • user - The address of the user
  • first_amount - The first payment amount

Returns

  • The computed required amount
fn compute_required_amount(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    limit_period: u64,
    token_price: i128,
    user: soroban_sdk::Address,
    first_amount: i128,
) -> i128

Gets the required amount for a payment

Arguments

  • env - The Soroban environment
  • token - The address of the token
  • payment_id - The ID of the payment
  • app_id - The ID of the app
  • user - The address of the user
  • choosenperiod - The chosen period for the payment

Returns

  • Tuple containing whether the token is supported and the required amount

Panics

  • If the payment is not found
fn get_required_amount(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    payment_id: soroban_sdk::BytesN<32>,
    app_id: u64,
    user: soroban_sdk::Address,
    choosenperiod: u64,
) -> (bool, i128)

Gets the index of a token in a payment's token list

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app
  • payment_id - The ID of the payment
  • token - The address of the token

Returns

  • The index of the token in the payment's token list

Panics

  • If the payment is not found
  • If the token is not found in the payment
fn index_of_token_payment(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
    token: soroban_sdk::Address,
) -> u32

Checks if a user requires more allowance for a payment

Arguments

  • env - The Soroban environment
  • token - The address of the token
  • payment_id - The ID of the payment
  • app_id - The ID of the app
  • user - The address of the user
  • choosenperiod - The chosen period for the payment

Returns

  • True if the user needs more allowance, false otherwise
fn require_allowance(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    payment_id: soroban_sdk::BytesN<32>,
    app_id: u64,
    user: soroban_sdk::Address,
    choosenperiod: u64,
) -> bool

Creates a new subscription

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app
  • payment_id - The ID of the payment
  • token - The address of the token
  • choosenperiod - The chosen period for the subscription
  • user - The address of the user

Panics

  • If the payment is not found
  • If the user is already subscribed
  • If the token is not supported
fn create_subscription(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
    token: soroban_sdk::Address,
    choosenperiod: u64,
    user: soroban_sdk::Address,
) -> soroban_sdk::BytesN<32>
fn payment_due(
    env: soroban_sdk::Env,
    subscription_id: soroban_sdk::BytesN<32>,
) -> (bool, bool)
fn automate_payment(env: soroban_sdk::Env, user_subs: soroban_sdk::BytesN<32>)

Cancels a subscription

Arguments

  • env - The Soroban environment
  • subscription_id - The ID of the subscription
  • app_id - The ID of the app

Panics

  • If the subscription is not found
  • If the caller is not the subscription owner
fn cancel_subscription(
    env: soroban_sdk::Env,
    subscription_id: soroban_sdk::BytesN<32>,
    app_id: u64,
)

Processes a subscription payment

Arguments

  • env - The Soroban environment
  • subscription_id - The ID of the subscription

Panics

  • If the subscription is not found
  • If the payment is not due
fn process_subscription(
    env: soroban_sdk::Env,
    subscription_id: soroban_sdk::BytesN<32>,
)

Deletes a specific payment from an app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app containing the payment
  • payment_id - The ID of the payment to delete

Panics

  • If the caller is not the app owner
  • If the payment is not found
fn delete_payment(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
)

Deletes all payments associated with an app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app whose payments will be deleted

Panics

  • If the caller is not the app owner
fn delete_all_payments(env: soroban_sdk::Env, app_id: u64)

Changes a token payment configuration

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app containing the payment
  • payment_id - The ID of the payment to modify
  • old_token - The current token address
  • new_token - The new token address
  • new_price - The new price for the token
  • first_amount - The new first payment amount

Panics

  • If the caller is not the app owner
  • If the payment is not found
  • If the new token already exists in the payment
fn change_token_payment(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
    old_token: soroban_sdk::Address,
    new_token: soroban_sdk::Address,
    new_price: i128,
    first_amount: i128,
)

Modifies a payment's configuration

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app containing the payment
  • payment_id - The ID of the payment to modify
  • name - The new name for the payment
  • owner - The new owner address
  • fee - The new fee percentage (in basis points)
  • trial_period - The new trial period duration
  • loading_time - The new loading time

Panics

  • If the caller is not the app owner
  • If the payment is not found
fn modify_payment(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
    name: soroban_sdk::BytesN<32>,
    owner: soroban_sdk::Address,
    fee: u64,
    trial_period: u64,
    loading_time: u64,
)

Adds a new token to an existing payment

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app containing the payment
  • payment_id - The ID of the payment to modify
  • new_token - The address of the token to add
  • price - The price for the token
  • first_amount - The first payment amount

Panics

  • If the caller is not the app owner
  • If the payment is not found
  • If the token already exists in the payment
fn add_token_payment_to_my_app(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
    new_token: soroban_sdk::Address,
    price: i128,
    first_amount: i128,
)

Removes a token from an existing payment

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app containing the payment
  • payment_id - The ID of the payment to modify
  • token - The address of the token to remove

Panics

  • If the caller is not the app owner
  • If the payment is not found
  • If the token is not found in the payment
fn remove_token_payment_from_my_app(
    env: soroban_sdk::Env,
    app_id: u64,
    payment_id: soroban_sdk::BytesN<32>,
    token: soroban_sdk::Address,
)

Pays the remaining amount for a subscription period

Arguments

  • env - The Soroban environment
  • subscription_id - The ID of the subscription

Panics

  • If the subscription is not found
  • If the caller is not the subscription owner
fn refund_subscription(env: soroban_sdk::Env, subscription_id: soroban_sdk::BytesN<32>)

Migrates a subscription to a new payment method

Arguments

  • env - The Soroban environment
  • subscription_id - The ID of the subscription to migrate
  • new_payment_id - The ID of the new payment method
  • new_token - The address of the new token

Panics

  • If the subscription is not found
  • If the caller is not the subscription owner
  • If the new payment is not found
  • If the new token is not supported
  • If trying to migrate to the same payment
  • If the period multiplier is invalid
  • If the user doesn't have sufficient allowance
fn migrate_to_new_payment(
    env: soroban_sdk::Env,
    subscription_id: soroban_sdk::BytesN<32>,
    new_payment_id: soroban_sdk::BytesN<32>,
    new_token: soroban_sdk::Address,
)

Manually renews a subscription

Arguments

  • env - The Soroban environment
  • subscription_id - The ID of the subscription to renew

Panics

  • If the subscription is not found
  • If the caller is not the subscription owner
  • If the subscription is not active
fn renew_subscription(env: soroban_sdk::Env, subscription_id: soroban_sdk::BytesN<32>)

Checks if a user is subscribed to an app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app
  • user - The address of the user to check

Returns

  • Tuple containing:
  • Whether the user is subscribed
  • Whether the user is in trial period
  • The payment ID
  • The subscription ID
fn is_my_subscriber(
    env: soroban_sdk::Env,
    app_id: u64,
    user: soroban_sdk::Address,
) -> (bool, bool, soroban_sdk::BytesN<32>, soroban_sdk::BytesN<32>)

Deletes an app and its associated data

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app to delete

Panics

  • If the caller is not the app owner
  • If the app is not found
fn delete_app(env: soroban_sdk::Env, app_id: u64)

Gets all apps owned by a specific address

Arguments

  • env - The Soroban environment
  • owner - The address of the owner

Returns

  • Option containing a vector of app IDs if found, None otherwise
fn get_app_by_owner(
    env: soroban_sdk::Env,
    owner: soroban_sdk::Address,
) -> Option>

Transfers ownership of an app to a new owner

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app
  • new_owner - The address of the new owner

Panics

  • If the caller is not the current app owner
  • If the new owner is the zero address
  • If the new owner is the same as the current owner
  • If the app is not found
fn transfer_app_ownership(
    env: soroban_sdk::Env,
    app_id: u64,
    new_owner: soroban_sdk::Address,
)

Renounces ownership of an app

Arguments

  • env - The Soroban environment
  • app_id - The ID of the app

Panics

  • If the caller is not the current app owner
  • If the app is not found
fn renounce_app_ownership(env: soroban_sdk::Env, app_id: u64)

Imports

WebAssembly Text (WAT) ▶