invite

UserService::InviteNs::Invite

struct UserService::InviteNs::Invite {
    const psibase::AccountNumber service; 

    Invite(...);        
    init(...);          
    getInvCost(...);    // Returns the current minimum cost of creating an invite that can create the specified number of accounts.
    createInvite(...);  // Creates and stores a new invite object that can be used to create new accounts Returns the ID of the newly created invite
    createAccount(...); // Called by an invite credential (not a user account) to create the specified account. The new account is authorized by the specified public key.
    accept(...);        // The sender accepts an invite. Calling this action also requires that the sender authorizes the transaction with the proof for the credential associated with the invite.
    delInvite(...);     // Delete the invite and its secret (if applicable). Can only be called by the invite creator.
    getInvite(...);     // Called synchronously by other services to retrieve the specified invite record
};

This service facilitates the creation and redemption of invites.

Invites are generic and their acceptance can, but does not always, result in the creation of a new account. This service can be used by third party applications to streamline their user onboarding.

UserService::InviteNs::Invite::Invite

UserService::InviteNs::Invite::Invite(
    psio::shared_view_ptr<psibase::Action> action
);

UserService::InviteNs::Invite::init

void UserService::InviteNs::Invite::init();

UserService::InviteNs::Invite::getInvCost

Quantity UserService::InviteNs::Invite::getInvCost(
    uint16_t numAccounts
);

Returns the current minimum cost of creating an invite that can create the specified number of accounts..

UserService::InviteNs::Invite::createInvite

uint32_t UserService::InviteNs::Invite::createInvite(
    uint32_t              inviteId,
    psibase::Checksum256  fingerprint,
    uint16_t              numAccounts,
    bool                  useHooks,
    std::string           secret,
    UserService::Quantity resources
);

Creates and stores a new invite object that can be used to create new accounts Returns the ID of the newly created invite.

Parameters:

  • inviteId is the id of the invite (could be randomly generated)
  • fingerprint is the fingerprint of the invite public key
  • numAccounts is the number of accounts this invite can be used to create
  • useHooks is a flag that indicates whether to use hooks to notify the caller when the invite is updated
  • secret is an encrypted secret used to redeem the invite
  • resources is the amount of resources stored in the invite (used when creating new accounts). The caller must send this amount of system tokens to this invite service before calling this action. Use the query interface to check the resources required for an invite of the specified number of accounts.

If useHooks is true, the caller must be an account with a service deployed on it that implements the InviteHooks interface.

UserService::InviteNs::Invite::createAccount

void UserService::InviteNs::Invite::createAccount(
    psibase::AccountNumber account,
    Spki                   accountKey
);

Called by an invite credential (not a user account) to create the specified account. The new account is authorized by the specified public key..

UserService::InviteNs::Invite::accept

void UserService::InviteNs::Invite::accept(
    uint32_t inviteId
);

The sender accepts an invite. Calling this action also requires that the sender authorizes the transaction with the proof for the credential associated with the invite..

UserService::InviteNs::Invite::delInvite

void UserService::InviteNs::Invite::delInvite(
    uint32_t inviteId
);

Delete the invite and its secret (if applicable). Can only be called by the invite creator..

UserService::InviteNs::Invite::getInvite

std::optional<InviteRecord> UserService::InviteNs::Invite::getInvite(
    uint32_t inviteId
);

Called synchronously by other services to retrieve the specified invite record.

UserService::InviteNs::InviteRecord

struct UserService::InviteNs::InviteRecord {
    uint32_t               id;          // The id of the invite (not sequential)
    uint32_t               cid;         // The id of the credential associated with the invite
    psibase::AccountNumber inviter;     // The creator of the invite object
    uint16_t               numAccounts; // Represents the number of accounts this invite can be used to create
    bool                   useHooks;    // A flag that represents whether to use hooks to notify the inviter when the invite is updated
    std::string            secret;      // The encrypted secret used to redeem the invite
};

An invite object.