Contract f810e6d51153fc8365d1348a34349af2b2d1fe0903b81b6e25d6187353364552

← Back to Index 📥 Download WASM

Meta

binver 3.0.0
desc Batch operations for plant, work, and harvest - reduces transactions by 90%
rssdkver 23.0.3#6aa930b08eabfd578b7824a0d5de473cbd958282
rsver 1.90.0
title KALE Batch Tractor - Full Lifecycle

Instances

  • CCAIRM4KJPA6V67HEG5UKRN4LDDVUBXEBV44QT3ILEYMFGREAVDPKOWE

Interface

Initialize the contract with farm address

fn __constructor(env: soroban_sdk::Env, farm: soroban_sdk::Address)

Batch plant operation - plants for multiple farmers at once

Arguments

  • farmers - Vector of farmer addresses (max 10)
  • amounts - Vector of stake amounts in stroops (1 KALE = 10_000_000 stroops)

Returns

Vector of boolean success status for each farmer

Example

let farmers = vec![&env, farmer1, farmer2, farmer3];
let amounts = vec![&env, 10_000_000, 20_000_000, 15_000_000];
let results = batch_plant(env, farmers, amounts);
// results = [true, true, true] if all succeeded
fn batch_plant(
    env: soroban_sdk::Env,
    farmers: soroban_sdk::Vec,
    amounts: soroban_sdk::Vec,
) -> soroban_sdk::Vec

Batch work submission - submits mining results for multiple farmers

Arguments

  • farmers - Vector of farmer addresses (max 10)
  • hashes - Vector of mining result hashes (32 bytes each)
  • nonces - Vector of mining nonces

Returns

Vector of gap values (i128) for each farmer Returns 0 if work failed for a farmer

Example

let farmers = vec![&env, farmer1, farmer2];
let hashes = vec![&env, hash1, hash2];
let nonces = vec![&env, 12345, 67890];
let gaps = batch_work(env, farmers, hashes, nonces);
// gaps = [150, 200] - gap values returned from contract
fn batch_work(
    env: soroban_sdk::Env,
    farmers: soroban_sdk::Vec,
    hashes: soroban_sdk::Vec>,
    nonces: soroban_sdk::Vec,
) -> soroban_sdk::Vec

Batch harvest - harvests rewards for multiple farmers

Arguments

  • farmers - Vector of farmer addresses (max 10)
  • blocks - Vector of block numbers to harvest

Returns

Vector of reward amounts (i128) for each farmer in stroops Returns 0 if harvest failed for a farmer

Example

let farmers = vec![&env, farmer1, farmer2, farmer3];
let blocks = vec![&env, 12340, 12340, 12340]; // same block
let rewards = batch_harvest(env, farmers, blocks);
// rewards = [5_000_000, 3_000_000, 4_000_000] in stroops
fn batch_harvest(
    env: soroban_sdk::Env,
    farmers: soroban_sdk::Vec,
    blocks: soroban_sdk::Vec,
) -> soroban_sdk::Vec

Get the configured farm contract address

fn get_farm(env: soroban_sdk::Env) -> soroban_sdk::Address

Utility function to check maximum supported batch size

fn max_batch_size(env: soroban_sdk::Env) -> u32

Imports

WebAssembly Text (WAT) ▶