Roloi is a payment customization platform that provides money streams, recurring and conditional payments. Roloi converts money into a fluid asset that can flow through a blockchain network. In a dynamic financial world, dynamic payments are necessary.
To compile the smart contract, Rust and Cargo are required. Here is an installation guide.
cargo-contract is required too. Install it using this command:
cargo install cargo-contract --force
To run the tests off-chain, execute this command:
cargo +nightly contract test
To generate the technical documentation, execute this command:
cargo doc
To compile the smart contract and generates the optimized WebAssembly bytecode, the metadata and bundles, execute this command:
cargo +nightly contract build
Open the Substrate Contracts-UI.
Choose a chain in the dropdown placed in the top section of the left menu.
Follow the ink! guide to upload and instantiate the smart contract.
pub struct Stream {
pub payer: AccountId,
pub recipient: AccountId,
pub original_balance: u128,
pub current_balance: u128,
pub start_date: u64,
pub end_date: u64
}#[ink(storage)]
#[derive(SpreadAllocate)]
pub struct StreamsContract {
owner: AccountId,
next_stream_id: u64,
streams: Mapping<u64, Stream>
}Creates a token stream from the sender to the specified recipient setting the end date or the duration.
create_stream(
recipient: AccountId,
end_date: Option<u64>,
duration: Option<u64>,
) -> Result<u64, ContractError>Parameters:
recipient: The recipient wallet address of the stream.end_date: The end date of the stream measured in seconds. If not specified, the stream will be created with the duration.duration: The duration of the stream measured in seconds. If not specified, the stream will be created with the end date.- Transaction funds: The amount of funds to be transferred to the recipient through the stream.
Returns:
- The created stream ID.
Examples:
- Using
end_date: 01/01/2024 01:00:00 GMT
create_stream(
"5FPE9bPa2yx8dhREN6iZ3PhAJqhbY87Gfg4ELJiRt8P5xUqN",
Some(1704070800),
None
);- Using
duration: 5 minutes
create_stream(
"5FPE9bPa2yx8dhREN6iZ3PhAJqhbY87Gfg4ELJiRt8P5xUqN",
None,
Some(300)
);Withdraws tokens from a stream. The recipient can specify the expected amount of tokens or withdraw all the available balance.
recipient_withdraw(
stream_id: u64,
withdrawal_amount: Option<u128>,
) -> Result<u128, ContractError>Parameters:
stream_id: The stream ID.withdrawal_amount: The amount of tokens to be withdrawn. If not specified, all the available balance will be withdrawn.
Returns:
- The amount of tokens withdrawn.
Examples:
- Specifying
withdrawal_amount: 1000
recipient_withdraw(1, Some(1000));- Without specifying
withdrawal_amount
recipient_withdraw(1, None);Returns a stream by its ID.
get_stream_by_id(
stream_id: u64
) -> Result<Stream, ContractError>Parameters:
stream_id: The expected stream ID.
Returns:
- The expected stream.
Example:
get_stream_by_id(1);