Skip to main content

CampaignInfo

Per-campaign configuration and state. Each campaign deployed via the CampaignInfoFactory gets its own CampaignInfo contract that tracks funding progress, accepted tokens, platform settings, and NFT pledge records.

const ci = oak.campaignInfo('0x...campaignAddress');

Methods

Reads

MethodReturnsDescription
getLaunchTime()bigintCampaign launch timestamp (seconds)
getDeadline()bigintCampaign deadline timestamp (seconds)
getGoalAmount()bigintFunding goal in currency units
getCampaignCurrency()Hexbytes32 currency identifier
getIdentifierHash()HexCampaign identifier hash
checkIfPlatformSelected(platformBytes)booleanWhether a platform is selected
checkIfPlatformApproved(platformHash)booleanWhether a platform is approved
getPlatformAdminAddress(platformBytes)AddressPlatform admin address
getPlatformData(platformDataKey)HexPlatform-specific data value
getPlatformFeePercent(platformBytes)bigintPlatform fee in basis points
getPlatformClaimDelay(platformHash)bigintPlatform claim delay in seconds
getProtocolAdminAddress()AddressProtocol admin address
getProtocolFeePercent()bigintProtocol fee in basis points
getAcceptedTokens()Address[]List of accepted ERC-20 token addresses
isTokenAccepted(token)booleanWhether a token is accepted
getTotalRaisedAmount()bigintCurrent raised amount
getTotalLifetimeRaisedAmount()bigintTotal ever raised (including refunded)
getTotalRefundedAmount()bigintTotal refunded amount
getTotalAvailableRaisedAmount()bigintAvailable raised (raised minus refunded)
getTotalCancelledAmount()bigintTotal cancelled amount
getTotalExpectedAmount()bigintTotal expected pending amount
getDataFromRegistry(key)HexRegistry data value
getBufferTime()bigintBuffer time in seconds
getLineItemType(platformHash, typeId)LineItemTypeInfoLine item type configuration
getCampaignConfig()CampaignConfigFull campaign configuration
getApprovedPlatformHashes()Hex[]List of approved platform hashes
isLocked()booleanWhether the campaign is locked
cancelled()booleanWhether the campaign is cancelled
owner()AddressContract owner
paused()booleanWhether the campaign is paused

Writes

All write methods return Promise<Hex> (transaction hash).

MethodDescription
updateDeadline(deadline)Update campaign deadline
updateGoalAmount(goalAmount)Update funding goal
updateLaunchTime(launchTime)Update launch time
updateSelectedPlatform(platformHash, selection, platformDataKey, platformDataValue)Add or remove a platform
setImageURI(newImageURI)Update NFT image URI
updateContractURI(newContractURI)Update contract metadata URI
mintNFTForPledge(backer, reward, tokenAddress, amount, shippingFee, tipAmount)Mint a pledge NFT for a backer
burn(tokenId)Burn a pledge NFT
pauseCampaign(message)Pause the campaign
unpauseCampaign(message)Unpause the campaign
cancelCampaign(message)Cancel the campaign
setPlatformInfo(platformBytes, platformTreasuryAddress)Set platform treasury address
transferOwnership(newOwner)Transfer contract ownership
renounceOwnership()Renounce contract ownership

Usage examples

Read campaign state

const launchTime  = await ci.getLaunchTime();
const deadline = await ci.getDeadline();
const goal = await ci.getGoalAmount();
const raised = await ci.getTotalRaisedAmount();
const currency = await ci.getCampaignCurrency();
const isCancelled = await ci.cancelled();

console.log('Goal:', goal, '| Raised:', raised);
console.log('Currency:', currency);
console.log('Cancelled:', isCancelled);

Get full campaign configuration

const config = await ci.getCampaignConfig();

console.log('Treasury factory:', config.treasuryFactory);
console.log('Protocol fee:', config.protocolFeePercent, 'bps');
console.log('Identifier:', config.identifierHash);

Update campaign deadline

import { addDays, getCurrentTimestamp } from '@oaknetwork/contracts';

const newDeadline = addDays(getCurrentTimestamp(), 60);
const txHash = await ci.updateDeadline(newDeadline);
await oak.waitForReceipt(txHash);

Pause and cancel

import { toHex } from '@oaknetwork/contracts';

// Pause
const pauseTx = await ci.pauseCampaign(toHex('Maintenance window', { size: 32 }));
await oak.waitForReceipt(pauseTx);

// Unpause
const unpauseTx = await ci.unpauseCampaign(toHex('Maintenance complete', { size: 32 }));
await oak.waitForReceipt(unpauseTx);

// Cancel
const cancelTx = await ci.cancelCampaign(toHex('Campaign ended early', { size: 32 }));
await oak.waitForReceipt(cancelTx);

Check accepted tokens

const tokens = await ci.getAcceptedTokens();
console.log('Accepted tokens:', tokens);

const isAccepted = await ci.isTokenAccepted('0x...tokenAddress');
console.log('Token accepted:', isAccepted);