Initializes the contract with admin and reserve addresses
env - The Soroban environmentadmin - The address of the adminreserve - The address of the reservefn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
reserve: soroban_sdk::Address,
)
Gets the admin address
env - The Soroban environmentfn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address
Gets the reserve address
env - The Soroban environmentfn get_reserve(env: soroban_sdk::Env) -> soroban_sdk::Address
Gets the protocol default fee
env - The Soroban environmentfn get_subs_fee(env: soroban_sdk::Env) -> u32
Updates the protocol fee
env - The Soroban environmentfee - The new fee percentage (in basis points)fn update_fee(env: soroban_sdk::Env, fee: u32)
Updates the reserve address
env - The Soroban environmentreserve - The new reserve addressfn update_reserve(env: soroban_sdk::Env, reserve: soroban_sdk::Address)
Updates the app fee for a specific app
env - The Soroban environmentcaller - The address of the callerapp_id - The ID of the appfee - The new fee percentage (in basis points)fn update_app_fees(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
app_id: u64,
fee: u64,
)
Gets the total number of apps
env - The Soroban environmentfn total_apps(env: soroban_sdk::Env) -> u64
Gets a specific app by ID
env - The Soroban environmentapp_id - The ID of the app to getfn get_app(env: soroban_sdk::Env, app_id: u64) -> Option
Gets the fee for a specific app
env - The Soroban environmentapp_id - The ID of the appfn get_app_fee(env: soroban_sdk::Env, app_id: u64) -> u64
Gets the owner of a specific app
env - The Soroban environmentapp_id - The ID of the appfn get_app_owner(env: soroban_sdk::Env, app_id: u64) -> Option
Gets all apps owned by a user
env - The Soroban environmentuser - The address of the userfn get_user_apps(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
) -> Option>
Gets the number of apps owned by an address
env - The Soroban environmentowner - The address of the ownerfn get_owner_app_count(env: soroban_sdk::Env, owner: soroban_sdk::Address) -> u64
Gets a specific payment for an app
env - The Soroban environmentapp_id - The ID of the apppayment_id - The ID of the paymentfn get_app_payment(
env: soroban_sdk::Env,
app_id: u64,
payment_id: soroban_sdk::BytesN<32>,
) -> Option
Gets all payments for an app
env - The Soroban environmentapp_id - The ID of the appfn get_app_payments(
env: soroban_sdk::Env,
app_id: u64,
) -> Option>>
Gets a specific subscription
env - The Soroban environmentsubs_id - The ID of the subscriptionfn get_subscription(
env: soroban_sdk::Env,
subs_id: soroban_sdk::BytesN<32>,
) -> Option
Gets all subscriptions for a user
env - The Soroban environmentuser - The address of the userfn get_user_subscriptions(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
) -> Option>>
Gets all subscribers for a specific payment in an app
env - The Soroban environmentapp_id - The ID of the apppayment_id - The ID of the paymentfn get_app_subscribers(
env: soroban_sdk::Env,
app_id: u64,
payment_id: soroban_sdk::BytesN<32>,
) -> Option>
Gets all subscriptions for an app
env - The Soroban environmentapp_id - The ID of the appfn get_app_subscriptions(
env: soroban_sdk::Env,
app_id: u64,
) -> Option>>
Checks if a subscription is canceled
env - The Soroban environmentsubs_id - The ID of the subscriptionfn 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
env - The Soroban environmentuser - The address of the userapp_id - The ID of the appfn get_already_trial_subscribed(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
app_id: u64,
) -> bool
Gets a specific one-time payment
env - The Soroban environmentotp_id - The ID of the one-time paymentfn 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
env - The Soroban environmentpayment_id - The ID of the paymentfn 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
env - The Soroban environmentuser - The address of the userapp_id - The ID of the apppayment_id - The ID of the paymentfn 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
env - The Soroban environmentname - The name of the apppayments - Vector of payment configurationscreatoraddress - The address of the app creatorfn 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
env - The Soroban environmentuser - The address of the usertokenaddress - The address of the token contractfn get_allowance(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
tokenaddress: soroban_sdk::Address,
) -> i128
Calculates the required amount for a subscription
env - The Soroban environmentsubscription_id - The ID of the subscriptionfn require_amount(
env: soroban_sdk::Env,
subscription_id: soroban_sdk::BytesN<32>,
) -> i128
Computes the required amount for a token payment
env - The Soroban environmenttoken - The address of the tokenlimit_period - The limit period for the paymenttoken_price - The price of the tokenuser - The address of the userfirst_amount - The first payment amountfn 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
env - The Soroban environmenttoken - The address of the tokenpayment_id - The ID of the paymentapp_id - The ID of the appuser - The address of the userchoosenperiod - The chosen period for the paymentfn 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
env - The Soroban environmentapp_id - The ID of the apppayment_id - The ID of the paymenttoken - The address of the tokenfn 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
env - The Soroban environmenttoken - The address of the tokenpayment_id - The ID of the paymentapp_id - The ID of the appuser - The address of the userchoosenperiod - The chosen period for the paymentfn 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
env - The Soroban environmentapp_id - The ID of the apppayment_id - The ID of the paymenttoken - The address of the tokenchoosenperiod - The chosen period for the subscriptionuser - The address of the userfn 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
env - The Soroban environmentsubscription_id - The ID of the subscriptionapp_id - The ID of the appfn cancel_subscription(
env: soroban_sdk::Env,
subscription_id: soroban_sdk::BytesN<32>,
app_id: u64,
)
Processes a subscription payment
env - The Soroban environmentsubscription_id - The ID of the subscriptionfn process_subscription(
env: soroban_sdk::Env,
subscription_id: soroban_sdk::BytesN<32>,
)
Deletes a specific payment from an app
env - The Soroban environmentapp_id - The ID of the app containing the paymentpayment_id - The ID of the payment to deletefn delete_payment(
env: soroban_sdk::Env,
app_id: u64,
payment_id: soroban_sdk::BytesN<32>,
)
Deletes all payments associated with an app
env - The Soroban environmentapp_id - The ID of the app whose payments will be deletedfn delete_all_payments(env: soroban_sdk::Env, app_id: u64)
Changes a token payment configuration
env - The Soroban environmentapp_id - The ID of the app containing the paymentpayment_id - The ID of the payment to modifyold_token - The current token addressnew_token - The new token addressnew_price - The new price for the tokenfirst_amount - The new first payment amountfn 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
env - The Soroban environmentapp_id - The ID of the app containing the paymentpayment_id - The ID of the payment to modifyname - The new name for the paymentowner - The new owner addressfee - The new fee percentage (in basis points)trial_period - The new trial period durationloading_time - The new loading timefn 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
env - The Soroban environmentapp_id - The ID of the app containing the paymentpayment_id - The ID of the payment to modifynew_token - The address of the token to addprice - The price for the tokenfirst_amount - The first payment amountfn 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
env - The Soroban environmentapp_id - The ID of the app containing the paymentpayment_id - The ID of the payment to modifytoken - The address of the token to removefn 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
env - The Soroban environmentsubscription_id - The ID of the subscriptionfn refund_subscription(env: soroban_sdk::Env, subscription_id: soroban_sdk::BytesN<32>)
Migrates a subscription to a new payment method
env - The Soroban environmentsubscription_id - The ID of the subscription to migratenew_payment_id - The ID of the new payment methodnew_token - The address of the new tokenfn 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
env - The Soroban environmentsubscription_id - The ID of the subscription to renewfn renew_subscription(env: soroban_sdk::Env, subscription_id: soroban_sdk::BytesN<32>)
Checks if a user is subscribed to an app
env - The Soroban environmentapp_id - The ID of the appuser - The address of the user to checkfn 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
env - The Soroban environmentapp_id - The ID of the app to deletefn delete_app(env: soroban_sdk::Env, app_id: u64)
Gets all apps owned by a specific address
env - The Soroban environmentowner - The address of the ownerfn get_app_by_owner(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
) -> Option>
Transfers ownership of an app to a new owner
env - The Soroban environmentapp_id - The ID of the appnew_owner - The address of the new ownerfn transfer_app_ownership(
env: soroban_sdk::Env,
app_id: u64,
new_owner: soroban_sdk::Address,
)
Renounces ownership of an app
env - The Soroban environmentapp_id - The ID of the appfn renounce_app_ownership(env: soroban_sdk::Env, app_id: u64)