Elfo Protocol enables subscription payment on Solana blockchain.
The protocol consists of three main componenets.
[This Repository]
[ github.com/elfo-protocol/elfo-node ]
[github.com/elfo-protocol/elfo-sdk]
This repository contains the core program of the elfo protocol.
To use elfo-ptotocol
for CPI, add elfo-protocol-core
under [dependencies]
in cargo.toml
file. Make sure "cpi"
feature is enabled.
[dependencies]
...
elfo-protocol-core = {version="0.1.0", features=["cpi"]}
Instructions listed bellow makes up the protocol.
Creates a subscription plan.
create_subscription_plan(
plan_name
,
subscription_amount
,
frequency
,
feePercentage
):
Name | Type | Description |
---|---|---|
plan_name |
String |
A string mentioning a name for subscription plan |
subscription_amount |
i64 |
Subscription amount in USDC with decimals |
frequency |
i64 |
Subscription frequency in seconds |
feePercentage |
i8 |
An integer between 1 - 5 that specifies the percentage of the fees that goes to nodes. The higher the percentage, the more incentive for nodes to monitor and trigger payments. |
Name | Description | References & Notes |
---|---|---|
authority |
The account which creates the subscription plan. | Signer |
protocol_state |
The elfo protocol state account. | ELFO_PROTOCOL_STATE |
subscription_plan_author |
Subscription payment author account (init-if-needed). | SubscriptionPlanAuthor.address |
subscription_plan |
Subscription plan account (init). | SubscriptionPlan.address |
subscription_plan_payment_account |
USDC Associated Token account of subscription author to recieve payments. | getAssociateTokenAddress |
mint |
USDC mint account. | USDC Mint |
token_program |
Token Program | TOKEN_PROGRAM_ID |
associated_token_program |
Associated Token Program | ASSOCIATED_TOKEN_PROGRAM_ID |
system_program |
System Program | SystemProgram.programId |
rent |
Rent Program | SYSVAR_RENT_PUBKEY |
Delegates (approve) required tokens and subscribes to subscription plan.
subscribe ( how_many_cycles
)
Name | Type | Description |
---|---|---|
how_many_cycles |
i64 |
How many cycles should the funds be delegated to |
Name | Description | References & Notes |
---|---|---|
who_subscribes |
The account which subscribes to the plan. | Signer |
protocol_signer |
The elfo protocol signer account. | ELFO_PROTOCOL_SIGNER |
subscription |
Subscription account (init_if_needed) | Subscription.address |
subscriber |
Subscriber account (init_if_needed) | Subscriber.address |
subscriber_payment_account |
USDC Associated Token account of subscriber to delegate payments. | getAssociateTokenAddress |
subscription_plan |
Subscription plan account | SubscriptionPlan.address |
subscription_plan_payment_account |
USDC Associated Token account of subscription author to recieve payments. | getAssociateTokenAddress |
mint |
USDC mint account. | USDC Mint |
token_program |
Token Program | TOKEN_PROGRAM_ID |
associated_token_program |
Associated Token Program | ASSOCIATED_TOKEN_PROGRAM_ID |
system_program |
System Program | SystemProgram.programId |
rent |
Rent Program | SYSVAR_RENT_PUBKEY |
clock |
Clock Program | SYSVAR_CLOCK_PUBKEY |
Registers a Elfo node to the protocol. Only registered node can monitor and trigger payment to earn fees.
register_node ()
None
Name | Description | References & Notes |
---|---|---|
authority |
The account which registers the node (node authority) | Signer |
node |
Node account (init_if_needed) | ElfoNode.address |
node_payment_account |
USDC Associated Token account of node_payment_wallet to recieve USDC fee payments. |
getAssociateTokenAddress |
protocol_state |
The elfo protocol state account. | ELFO_PROTOCOL_STATE |
node_payment_wallet |
Wallet account used to get and verify node_payment_account |
|
mint |
USDC mint account. | USDC Mint |
token_program |
Token Program | TOKEN_PROGRAM_ID |
associated_token_program |
Associated Token Program | ASSOCIATED_TOKEN_PROGRAM_ID |
system_program |
System Program | SystemProgram.programId |
rent |
Rent Program | SYSVAR_RENT_PUBKEY |
Trigger a payment on a subscription. This is called by registered elfo-nodes.
trigger_payment ()
None
Name | Description | References & Notes |
---|---|---|
authority |
The account which registered the node (node authority) | Signer |
subscriber_payment_account |
USDC Associated Token account of subscriber to delegate payments. | getAssociateTokenAddress |
protocol_signer |
The elfo protocol signer account. | ELFO_PROTOCOL_SIGNER |
subscription |
Subscription account | Subscription.address |
subscriber |
Subscriber account | Subscriber.address |
subscription_plan_payment_account |
USDC Associated Token account of subscription author to recieve payments. | getAssociateTokenAddress |
subscription_plan |
Subscription plan account. | SubscriptionPlan.address |
node |
Node account | ElfoNode.address |
node_payment_account |
USDC Associated Token account of node_payment_wallet to recieve USDC fee payments. |
getAssociateTokenAddress |
node_payment_wallet |
Wallet account used to get and verify node_payment_account |
|
mint |
USDC mint account. | USDC Mint |
token_program |
Token Program | TOKEN_PROGRAM_ID |
clock |
Clock Program | SYSVAR_CLOCK_PUBKEY |
Unsubscribe from a subscription plan
unsubscribe ()
None
Name | Description | References & Notes |
---|---|---|
who_unsubscribes |
The account which unsubscribes from the plan. | Signer |
subscriber |
Subscriber account | Subscriber.address |
subscription_plan |
Subscription plan account. | SubscriptionPlan.address |
Closes a subscription plan
close_subscription_plan ()
None
Name | Description | References & Notes |
---|---|---|
authority |
The account which initially created the subscription plan | Signer |
subscription_plan_author |
Subscription payment author account. | SubscriptionPlanAuthor.address |
subscription_plan |
Subscription plan account. | SubscriptionPlan.address |
- Elfo Protocol is in active development, so all APIs are subject to change.
- Elfo protocol only supports USDC-SPL payments right now. In future this will be extended to support any SPL tokens
- This code is not audited yet. Use at your own risk.
Elfo Protocol is licensed under Apache 2.0.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Anchor by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.