Calling the contract
The website uses genlayer-js. Reads need no wallet. Writes go through any EIP-1193 provider, including the one an EIP-6963 wallet announces.
import { createClient } from "genlayer-js";
import { studionet } from "genlayer-js/chains";
const CONTRACT = "0xf49Fca785788a2a3881c593F33B2E20113FD99e1";
// Read, no wallet needed
const reader = createClient({ chain: studionet });
const bounty = await reader.readContract({
address: CONTRACT, functionName: "get_bounty",
args: ["0x174fbcdecffc4ada6bd69470fcea8dce760eac3e", "MAIN"],
});
// Write through a wallet provider found with EIP-6963
const client = createClient({ chain: studionet, account: accountAddress, provider: walletProvider });
const hash = await client.writeContract({
address: CONTRACT, functionName: "deposit_credit", args: [], value: 10n ** 17n,
});
A transaction can reach consensus while the contract rejected the call. After the status becomes ACCEPTED, read the leader receipt's execution result. The website does this for every write and shows the contract's own message.
If Studionet has fees enabled (sim_getFeeConfig returns enabled), estimate them with client.estimateTransactionFees() and pass them as fees. The website does this automatically.
Numbers above 253 come back from readContract as strings, so convert amounts with BigInt(value).
Data shapes
Bounty record
| Name | Type | Description |
|---|---|---|
| key | str | Lowercase sponsor:id. |
| bounty_id | str | The id. |
| sponsor | str | Sponsor address, lowercase. |
| scope | str | The scope text. |
| reward_wei | int | Reward per slot. |
| bond_wei | int | Bond per finding. |
| slots | int | Total slots. |
| heads | int | Slots already paid. |
| commit_by | int | Commit deadline, unix time. |
| reveal_window | int | Seconds allowed to reveal after each commit. |
| review_by | int | Review deadline, unix time. |
| created_at / closed_at | int | Unix times. closed_at is 0 while open. |
| escrow | int | Reward still held for unpaid slots. |
| finding_count | int | Findings committed so far. |
| cursor | int | Index of the earliest undecided finding. |
| status | str | open, closed or cancelled. |
| close_reason | str | all_slots_filled, review_deadline, commit_window_ended or cancelled_before_any_commit. |
Finding record
| Name | Type | Description |
|---|---|---|
| index | int | Queue position. |
| hunter | str | Hunter address, lowercase. |
| commitment | str | The committed fingerprint. |
| title / body | str | Empty until revealed. |
| status | str | committed, revealed, distinct, duplicate, invalid, unresolved, void or late. |
| committed_at / revealed_at / decided_at | int | Unix times, 0 when not reached. |
| reveal_by | int | Reveal deadline. |
| bond_wei / bond_state | int / str | Bond amount still held, and locked, refunded or forfeited_to_sponsor. |
| reward_wei | int | Reward paid, 0 unless distinct. |
| duplicate_of | int | Index of the accepted finding it duplicates, or -1. |
| in_scope / actionable | str | The validators' answers: yes, no, unclear, or empty. |
| confidence / rationale | int / str | Validator confidence 0 to 100 and a short explanation. |
| reason | str | Machine reason such as not_revealed_in_time or inconclusive_assessment. |
| attempts / failures | int | Inconclusive answers and operational failures so far. |
| retry_at | int | Earliest time the next review may run. |
Write methods
deposit_creditwrite payableAnyone, sends GENCredits the attached GEN to the actual sender. Send the value with the call, never as a plain transfer.
No arguments.
Returns. The amount credited, in wei.
Rejected with.
- Deposit must be positive
withdraw_creditwriteAnyone with creditSends the caller's whole available credit to the caller. It is the only method that emits a transfer. Locked funds are not affected.
No arguments.
Returns. The amount sent, in wei.
Rejected with.
- No available credit
- This method does not accept value
create_bountywriteSponsorLocks reward × slots from the sponsor's credit into escrow. The id is unique per sponsor, so two sponsors can use the same id.
| Name | Type | Description |
|---|---|---|
| bounty_id | str | 1 to 64 characters, [A-Za-z0-9][A-Za-z0-9_.-]*. |
| scope_text | str | 20 to 800 characters after whitespace is collapsed. |
| reward_wei | u256 | Reward per slot, 1014 to 1027. |
| slots | u16 | 1 to 8. |
| bond_wei | u256 | From 1012 up to the reward. |
| commit_by | u256 | Unix time. Between now + 10 minutes and now + 60 days. |
| reveal_window | u256 | Seconds, 300 to 604800, counted from each commit. |
| review_by | u256 | Unix time. Between commit_by + reveal_window + 1 day and + 90 days. |
Returns. The bounty key, sponsor:id in lowercase.
Rejected with.
- Invalid bounty id
- Invalid scope
- Invalid reward
- Invalid slot count
- Invalid bond
- Invalid reveal window
- Invalid commit deadline
- Invalid review deadline
- Duplicate bounty id
- Insufficient available credit
cancel_bountywriteSponsor onlyPossible only while the bounty is open and nobody has committed. Returns the whole escrow to the sponsor's credit.
| Name | Type | Description |
|---|---|---|
| bounty_id | str | The sponsor's bounty id. |
Returns. Nothing.
Rejected with.
- Bounty not found
- Bounty cannot be cancelled
close_bountywriteAnyoneAllowed after the review deadline, or once the commit deadline has passed and no finding is pending. Settles leftover bonds, returns unused escrow to the sponsor, and marks the bounty closed.
| Name | Type | Description |
|---|---|---|
| sponsor_text | str | Sponsor address, any case. |
| bounty_id | str | The sponsor's bounty id. |
Returns. Nothing.
Rejected with.
- Bounty is not open
- Bounty cannot be closed yet
commit_findingwriteAny hunter except the sponsorLocks the bond from the hunter's credit, appends the finding to the queue, and sets its reveal deadline to now + the reveal window.
| Name | Type | Description |
|---|---|---|
| sponsor_text | str | Sponsor address, any case. |
| bounty_id | str | The sponsor's bounty id. |
| commitment_text | str | 0x plus 64 hex characters, the SHA-256 fingerprint. |
Returns. The finding's index in the queue.
Rejected with.
- Commit window is closed
- Sponsor cannot submit findings
- All reward slots are filled
- Finding limit reached
- Per-hunter finding limit reached
- Invalid commitment
- Insufficient available credit
reveal_findingwriteThe committing hunterRecomputes the fingerprint from the revealed fields. If it matches, the text is stored and the finding becomes revealed. Text is validated, never trimmed or rewritten.
| Name | Type | Description |
|---|---|---|
| sponsor_text | str | Sponsor address, any case. |
| bounty_id | str | The sponsor's bounty id. |
| index | u16 | Position in the queue, starting at 0. |
| title | str | 1 to 120 characters, one line, exact. |
| body | str | 1 to 1200 characters, exact. |
| salt | str | 16 to 64 characters from A-Za-z0-9_-. |
Returns. Nothing.
Rejected with.
- Only the committing hunter may reveal
- Finding is not awaiting reveal
- Reveal window elapsed
- Invalid title
- Invalid body
- Invalid salt
- Reveal does not match commitment
void_unrevealedwriteAnyoneMarks a commitment whose reveal window has passed as void, sends its bond to the sponsor, and lets the queue advance.
| Name | Type | Description |
|---|---|---|
| sponsor_text | str | Sponsor address, any case. |
| bounty_id | str | The sponsor's bounty id. |
| index | u16 | Position in the queue, starting at 0. |
Returns. Nothing.
Rejected with.
- Finding cannot be voided
adjudicatewriteAnyoneDecides the earliest undecided finding. Runs the copy guard, then asks validators, then applies the decision table. This is the only method that calls a language model, so it takes longer than the others.
| Name | Type | Description |
|---|---|---|
| sponsor_text | str | Sponsor address, any case. |
| bounty_id | str | The sponsor's bounty id. |
Returns. The earliest finding's status after the call: distinct, duplicate, invalid, unresolved, or still revealed after an inconclusive answer.
Rejected with.
- Bounty is not open
- Review window elapsed
- No finding awaits adjudication
- Earliest finding awaits reveal or voiding
- Adjudication cooldown is active
View methods
get_creditviewAnyone| Name | Type | Description |
|---|---|---|
| owner_text | str | Address of the account. |
Returns. Available credit in wei.
Rejected with.
- Invalid credit owner
get_accountingviewAnyoneCompares what the contract owes with what it holds. A positive unallocated_balance means GEN arrived by plain transfer.
No arguments.
Returns. total_credits, total_locked, accounted_liabilities, contract_balance, unallocated_balance, balance_shortfall and solvent.
get_bountyviewAnyone| Name | Type | Description |
|---|---|---|
| sponsor_text | str | Sponsor address, any case. |
| bounty_id | str | The sponsor's bounty id. |
Returns. A bounty record, see the table below.
Rejected with.
- Bounty not found
get_findingviewAnyone| Name | Type | Description |
|---|---|---|
| sponsor_text | str | Sponsor address, any case. |
| bounty_id | str | The sponsor's bounty id. |
| index | u16 | Position in the queue, starting at 0. |
Returns. A finding record, see the table below.
Rejected with.
- Bounty not found
- Finding not found
get_findingsviewAnyone| Name | Type | Description |
|---|---|---|
| sponsor_text | str | Sponsor address, any case. |
| bounty_id | str | The sponsor's bounty id. |
Returns. Every finding of the bounty in queue order.
Rejected with.
- Bounty not found
get_infoviewAnyoneUseful for checking that a deployment is what you expect.
No arguments.
Returns. Name, version, commitment domain, every limit in this reference, and short descriptions of the priority rule, settlement model and bond policy.