Skip to content

Stratagems

Functions

getCell

return updated cell (based on current epoch)

sig hash: 0x206848f6

Signature: getCell(uint256)

function getCell(uint256 id) view returns ((address owner, uint24 lastEpochUpdate, uint24 epochWhenTokenIsAdded, uint24 producingEpochs, uint8 color, uint8 life, int8 delta, uint8 enemyMap, uint8 distribution, uint8 stake))

NameDescription
idthe cell id

getCells

return the list of updated cells (based on current epoch) whose ids is given

sig hash: 0xf18885ce

Signature: getCells(uint256[])

function getCells(uint256[] ids) view returns ((address owner, uint24 lastEpochUpdate, uint24 epochWhenTokenIsAdded, uint24 producingEpochs, uint8 color, uint8 life, int8 delta, uint8 enemyMap, uint8 distribution, uint8 stake)[] cells)

NameDescription
idsthe list of cell ids

getCommitment

The commitment to be revealed. zeroed if no commitment need to be made.

sig hash: 0xfa1026dd

Signature: getCommitment(address)

function getCommitment(address account) view returns ((bytes24 hash, uint24 epoch) commitment)

NameDescription
accountthe address of which to retrieve the commitment

getConfig

return the config used to initialise the Game

sig hash: 0xc3f909d4

Signature: getConfig()

function getConfig() view returns ((address tokens, address burnAddress, uint256 startTime, uint256 commitPhaseDuration, uint256 revealPhaseDuration, uint8 maxLife, uint256 numTokensPerGems, address time, address generator) config)

getTokensInReserve

the number of token in reserve per account This is used to slash player who do not reveal their moves The amount can be greater than the number of token required for the next move This allow player to potentially hide their intention.

sig hash: 0x990b0509

Signature: getTokensInReserve(address)

function getTokensInReserve(address account) view returns (uint256 amount)

NameDescription
accountthe address to retrived the amount in reserve of.

addToReserve

called by players to add tokens to their reserve

sig hash: 0xd6710112

Signature: addToReserve(uint256,(uint256,uint256,uint8,bytes32,bytes32))

function addToReserve(uint256 tokensAmountToAdd, (uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) permit)

NameDescription
tokensAmountToAddamount of tokens to add
permitpermit EIP2612, .value = zero if not needed

cancelCommitment

called by players to cancel their current commitment Can only be called during the commit phase in which the commitment was made It cannot be called afterward

sig hash: 0xafa1e2d1

Signature: cancelCommitment()

function cancelCommitment()

makeCommitment

called by players to commit their moves this can be called multiple time in the same epoch, the last call overriding the previous. When a commitment is made, it needs to be revealed in the reveal phase of the same epoch.abi If missed, player can still reveal its moves but none of them will be resolved. The player would lose its associated reserved amount.

sig hash: 0xae37a62d

Signature: makeCommitment(bytes24,address)

function makeCommitment(bytes24 commitmentHash, address payee) payable

NameDescription
commitmentHashthe hash of the moves
payeeaddress to send ETH to along the commitment. Can be used to pay for reveal

makeCommitmentWithExtraReserve

called to make a commitment along with tokens to add to the reserve

sig hash: 0x10837a39

Signature: makeCommitmentWithExtraReserve(bytes24,uint256,(uint256,uint256,uint8,bytes32,bytes32),address)

function makeCommitmentWithExtraReserve(bytes24 commitmentHash, uint256 tokensAmountToAdd, (uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) permit, address payee) payable

NameDescription
commitmentHashthe has of the moves
tokensAmountToAddamount of tokens to add to the reserve. the resulting total must be enough to cover the moves
permitpermit EIP2612, value = zero if not needed
payeeaddress to send ETH to along the commitment. Can be used to pay for reveal

withdrawFromReserve

called by players to withdraw tokens from the reserve can only be called if no commitments are pending Note that while you can withdraw after commiting, note that if you do not have enough tokens you'll have your commitment failing.

sig hash: 0x0a8bcdb9

Signature: withdrawFromReserve(uint256)

function withdrawFromReserve(uint256 amount)

NameDescription
amountnumber of tokens to withdraw

acknowledgeMissedReveal

called by player if they missed the reveal phase and want to minimze the token loss. By providing the moves, they will be slashed only the amount of token required to make the moves

sig hash: 0x599a71c6

Signature: acknowledgeMissedReveal(address,bytes32,(uint64,uint8)[],bytes24)

function acknowledgeMissedReveal(address player, bytes32 secret, (uint64 position, uint8 color)[] moves, bytes24 furtherMoves)

NameDescription
playerthe account who committed the move
secretthe secret used to make the commit
movesthe actual moves
furtherMovesif moves cannot be contained in one tx, further moves are represented by a hash to reveal too

acknowledgeMissedRevealByBurningAllReserve

should only be called as last resort this will burn all tokens in reserve If player has access to the secret, better call acknowledgeMissedReveal

sig hash: 0x1fdd8a69

Signature: acknowledgeMissedRevealByBurningAllReserve()

function acknowledgeMissedRevealByBurningAllReserve()

reveal

called by player to reveal their moves this is where the core logic of the game takes place This is where the game board evolves The game is designed so that reveal order does not matter

sig hash: 0xd4019783

Signature: reveal(address,bytes32,(uint64,uint8)[],bytes24,bool,address)

function reveal(address player, bytes32 secret, (uint64 position, uint8 color)[] moves, bytes24 furtherMoves, bool useReserve, address payee) payable

NameDescription
playerthe account who committed the move
secretthe secret used to make the commit
movesthe actual moves
furtherMovesif moves cannot be contained in one tx, further moves are represented by a hash to reveal too Note that you have to that have enough moves (specified by MAX_NUM_MOVES_PER_HASH = 32)
useReservewhether the tokens are taken from the reserve or from approvals. This allow player to keep their reserve intact and use it on their next move. Note that this require the Stratagems contract to have enough allowance.
payeeaddress to send ETH to along the reveal

pokeMultiple

poke and collect the tokens won across multiple cells

sig hash: 0x8b8fc3a1

Signature: pokeMultiple(uint64[])

function pokeMultiple(uint64[] positions)

NameDescription
positionscell positions to collect from

approve

Approve an operator to transfer a specific token on the senders behalf.

sig hash: 0x095ea7b3

Signature: approve(address,uint256)

function approve(address operator, uint256 tokenID)

NameDescription
operatorThe address receiving the approval.
tokenIDThe id of the token.

balanceOf

balanceOf is not implemented, keeping track of this add gas and we did not consider that worth it

sig hash: 0x70a08231

Signature: balanceOf(address)

function balanceOf(address) pure returns (uint256)

getApproved

Get the approved operator for a specific token.

sig hash: 0x081812fc

Signature: getApproved(uint256)

function getApproved(uint256 tokenID) view returns (address operator)

NameDescription
tokenIDThe id of the token.

isApprovedForAll

Check if the sender approved the operator to transfer any of its tokens.

sig hash: 0xe985e9c5

Signature: isApprovedForAll(address,address)

function isApprovedForAll(address owner, address operator) view returns (bool)

NameDescription
ownerThe address of the owner.
operatorThe address of the operator.

name

A descriptive name for a collection of NFTs in this contract

sig hash: 0x06fdde03

Signature: name()

function name() pure returns (string)

ownerAndLastTransferBlockNumberList

Get the list of owner of a token and the blockNumber of its last transfer, useful to voting mechanism.

sig hash: 0xf3945282

Signature: ownerAndLastTransferBlockNumberList(uint256[])

function ownerAndLastTransferBlockNumberList(uint256[] tokenIDs) view returns ((address owner, uint256 lastTransferBlockNumber)[] ownersData)

NameDescription
tokenIDsThe list of token ids to check.

ownerAndLastTransferBlockNumberOf

Get the owner of a token and the blockNumber of the last transfer, useful to voting mechanism.

sig hash: 0x48f3c51c

Signature: ownerAndLastTransferBlockNumberOf(uint256)

function ownerAndLastTransferBlockNumberOf(uint256 tokenID) view returns (address owner, uint256 blockNumber)

NameDescription
tokenIDThe id of the token.

ownerOf

Get the owner of a token.

sig hash: 0x6352211e

Signature: ownerOf(uint256)

function ownerOf(uint256 tokenID) view returns (address owner)

NameDescription
tokenIDThe id of the token.

safeTransferFrom

Transfer a token between 2 addresses letting the receiver know of the transfer.

sig hash: 0x42842e0e

Signature: safeTransferFrom(address,address,uint256)

function safeTransferFrom(address from, address to, uint256 tokenID)

NameDescription
fromThe send of the token.
toThe recipient of the token.
tokenIDThe id of the token.

safeTransferFrom

Transfer a token between 2 addresses letting the receiver knows of the transfer.

sig hash: 0x42842e0e

Signature: safeTransferFrom(address,address,uint256,bytes)

function safeTransferFrom(address from, address to, uint256 tokenID)

NameDescription
fromThe sender of the token.
toThe recipient of the token.
tokenIDThe id of the token.

setApprovalForAll

Set the approval for an operator to manage all the tokens of the sender.

sig hash: 0xa22cb465

Signature: setApprovalForAll(address,bool)

function setApprovalForAll(address operator, bool approved)

NameDescription
operatorThe address receiving the approval.
approvedThe determination of the approval.

supportsInterface

Query if a contract implements an interface

sig hash: 0x01ffc9a7

Signature: supportsInterface(bytes4)

function supportsInterface(bytes4 interfaceID) pure returns (bool)

NameDescription
interfaceIDThe interface identifier, as specified in ERC-165

symbol

An abbreviated name for NFTs in this contract

sig hash: 0x95d89b41

Signature: symbol()

function symbol() pure returns (string)

tokenURI

A distinct Uniform Resource Identifier (URI) for a given asset.

sig hash: 0xc87b56dd

Signature: tokenURI(uint256)

function tokenURI(uint256 tokenID) view returns (string)

NameDescription
tokenIDid of the token being queried.

transferFrom

Transfer a token between 2 addresses.

sig hash: 0x23b872dd

Signature: transferFrom(address,address,uint256)

function transferFrom(address from, address to, uint256 tokenID)

NameDescription
fromThe sender of the token.
toThe recipient of the token.
tokenIDThe id of the token.

Events

CommitmentCancelled

A player has cancelled its current commitment (before it reached the reveal phase)

event CommitmentCancelled(address indexed player, uint24 indexed epoch)

NameDescription
playeraccount taking the staking risk (can be a different account than the one controlling the gems)
epochepoch number on which this commit belongs to

CommitmentMade

A player has commited to make a move and reveal it on the reveal phase

event CommitmentMade(address indexed player, uint24 indexed epoch, bytes24 commitmentHash)

NameDescription
playeraccount taking the staking risk (can be a different account than the one controlling the gems)
epochepoch number on which this commit belongs to
commitmentHashthe hash of moves

CommitmentRevealed

Player has revealed its previous commitment

event CommitmentRevealed(address indexed player, uint24 indexed epoch, bytes24 indexed commitmentHash, (uint64 position, uint8 color)[] moves, bytes24 furtherMoves, uint256 newReserveAmount)

NameDescription
playeraccount who commited
epochepoch number on which this commit belongs to
commitmentHashthe hash of the moves
movesthe moves
furtherMoveshash of further moves, unless bytes32(0) which indicate end.
newReserveAmountnew amount in reserve as a result

CommitmentVoid

A player has canceled a previous commitment by burning some tokens

event CommitmentVoid(address indexed player, uint24 indexed epoch, uint256 amountBurnt, bytes24 furtherMoves)

NameDescription
playerthe account that made the commitment
epochepoch number on which this commit belongs to
amountBurntamount of token to burn
furtherMoveshash of further moves, unless bytes32(0) which indicate end.

MoveProcessed

A move has been revealed.

event MoveProcessed(uint64 indexed position, address indexed player, uint8 oldColor, uint8 newColor)

NameDescription
positioncell at which the move take place
playeraccount making the move
oldColorprevious color of the cell
newColorcolor that takes over

MultiPoke

poke multiple cells and update them if needed

event MultiPoke(uint24 indexed epoch, uint64[] positions)

NameDescription
epochepoch number at which the poke take place
positionscells to poke

ReserveDeposited

Player has deposited token in the reserve, allowing it to use that much in game

event ReserveDeposited(address indexed player, uint256 amountDeposited, uint256 newAmount)

NameDescription
playeraccount receiving the token in the reserve
amountDepositedthe number of tokens deposited
newAmountthe number of tokens in reserver as a result

ReserveWithdrawn

Player have withdrawn token from the reserve

event ReserveWithdrawn(address indexed player, uint256 amountWithdrawn, uint256 newAmount)

NameDescription
playeraccount withdrawing the tokens
amountWithdrawnthe number of tokens withdrawnn
newAmountthe number of tokens in reserver as a result

SinglePoke

poke cell and update it if needed

event SinglePoke(uint24 indexed epoch, uint64 position)

NameDescription
epochepoch number at which the poke take place
positioncell to poke

Approval

Triggered when a token is approved to be sent by another account Note tat the approval get reset when a Transfer event for that same token is emitted.

event Approval(address indexed owner, address indexed approved, uint256 indexed tokenID)

NameDescription
ownercurrent owner of the token
approvedaccount who can know transfer on the owner's behalf
tokenIDid of the token being approved

ApprovalForAll

Triggered when an account approve or disaprove another to transfer on its behalf

event ApprovalForAll(address indexed owner, address indexed operator, bool approved)

NameDescription
ownerthe account granting rights over all of its token
operatoraccount who can know transfer on the owner's behalf
approvedwhether it is approved or not

Transfer

Triggered when a token is transferred

event Transfer(address indexed from, address indexed to, uint256 indexed tokenID)

NameDescription
fromthe account the token is sent from
tothe account the token is sent to
tokenIDid of the token being sent

Errors

CanStillReveal

Player have to reveal if they can Stratagems will prevent them from acknowledging missed reveal if there is still time to reveal.

error CanStillReveal()

CommitmentHashNotMatching

Player have to reveal their commitment using the exact same move values If they provide different value, the commitment hash will differ and Stratagems will reject their reveal.

error CommitmentHashNotMatching()

GameNotStarted

Game has not started yet, can't perform any action

error GameNotStarted()

ImpossibleConfiguration

The cell configuration is invalid This can happen win debug mode where admin can setup cell bypassing moves rules For example when setting up neighborood configuration that would require a cell to have negative life

error ImpossibleConfiguration()

InCommitmentPhase

When in Commit phase, player can make new commitment but they cannot reveal their move yet.

error InCommitmentPhase()

InRevealPhase

When in Reveal phase, it is not possible to commit new moves or cancel previous commitment During Reveal phase, players have to reveal their commitment, if not already done.

error InRevealPhase()

InvalidEpoch

Player can only reveal their move in the same epoch they commited.abi If a player reveal later it can only do to minimize the reserve burn cost by calling : acknowledgeMissedReveal

error InvalidEpoch()

InvalidFurtherMoves

Player can make arbitrary number of moves per epoch. To do so they group moves into (MAX_NUM_MOVES_PER_HASH = 32) moves This result in a recursive series of hash that they can then submit in turn while revealing. The limit (MAX_NUM_MOVES_PER_HASH = 32) ensure a reveal batch fits in a block.

error InvalidFurtherMoves()

NothingToReveal

Player can only reveal moves they commited.

error NothingToReveal()

PreviousCommitmentNotRevealed

Previous commitment need to be revealed before making a new one. Even if the corresponding reveal phase has passed.

It is also not possible to withdraw any amount from reserve until the commitment is revealed.

If player lost the information to reveal, it can acknowledge failure which will burn all its reserve.

error PreviousCommitmentNotRevealed()

ReserveTooLow

to make a commitment you always need at least one config.numTokensPerGems amount in reserve Player also need one config.numTokensPerGems per moves during the Reveal phase.

error ReserveTooLow(uint256 inReserve, uint256 expected)

NameDescription
inReserveamount in reserver as the time of the call
expectedamount required to proceed

InvalidAddress

An invalid address is specified (for example: zero address)

error InvalidAddress(address addr)

NameDescription
addrinvalid address

NonExistentToken

The token does not exist

error NonExistentToken(uint256 tokenID)

NameDescription
tokenIDid of the expected token

NonceOverflow

The Nonce overflowed, make a transfer to self to allow new nonces.

error NonceOverflow()

NotAuthorized

Not authorized to perform this operation

error NotAuthorized()

NotImplemented

function is not implemented

error NotImplemented()

NotOwner

The address from which the token is sent is not the current owner

error NotOwner(address provided, address currentOwner)

NameDescription
providedthe address expected to be the current owner
currentOwnerthe current owner

TransferRejected

The Transfer was rejected by the destination

error TransferRejected()

Released under the GPL 3.0 License.