elfo-protocol-core

Crates.ioelfo-protocol-core
lib.rselfo-protocol-core
version0.1.0
sourcesrc
created_at2022-03-15 14:00:58.659432
updated_at2022-03-15 14:00:58.659432
descriptionA subscription protocol on solana
homepagehttps://eflo.cc/
repositoryhttps://github.com/elfo-protocol/elfo-core/
max_upload_size
id550498
size34,561
Irshad Nilam (irshadnilam)

documentation

https://elfo.cc/docs

README

Elfo Protocol

Protocol for Subscription Payments on Solana

Tutorials Discord Chat License

Elfo Protocol enables subscription payment on Solana blockchain.

The protocol consists of three main componenets.

Core program (smart contract)

[This Repository]

Elfo node CLI

[ github.com/elfo-protocol/elfo-node ]

Elfo Javascript SDK

[github.com/elfo-protocol/elfo-sdk]


Core Program

The program is written using anchor protocol. Instructions listed bellow makes up the protocol.

create_subscription_plan

Creates a subscription plan.

create_subscription_plan( plan_name, subscription_amount, frequency, feePercentage ):

Parameters

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.

Accounts

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

subscribe

Delegates (approve) required tokens and subscribes to subscription plan.

subscribe ( how_many_cycles )

Parameters

Name Type Description
how_many_cycles i64 How many cycles should the funds be delegated to

Accounts

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

register_node

Registers a Elfo node to the protocol. Only registered node can monitor and trigger payment to earn fees.

register_node ()

Parameters

None

Accounts

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_payment

Trigger a payment on a subscription. This is called by registered elfo-nodes.

trigger_payment ()

Parameters

None

Accounts

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

Unsubscribe from a subscription plan

unsubscribe ()

Parameters

None

Accounts

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

close_subscription_plan

Closes a subscription plan

close_subscription_plan ()

Parameters

None

Accounts

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

Note

  • 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.

License

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.

Commit count: 21

cargo fmt