Skip to main content

Staked Expenditure (StakedExpenditure)

This extension allows users without the Administration permission to create expenditures by posting a small stake. If the expenditure is refined and finalized without issue, then the stake is returned. If for whatever reason the creator is found to have acted inappropriately, they run the risk of losing their stake.

This is a Colony Extension which conforms to the extension interface found here.

Interface Methods

authority():DSAuthority authority

Get the authority of the contract

Return Parameters

NameTypeDescription
authorityDSAuthorityThe authority of the contract

cancelAndPunish(uint256 _permissionDomainId, uint256 _childSkillIndex, uint256 _callerPermissionDomainId, uint256 _callerChildSkillIndex, uint256 _expenditureId, bool _punish)

Can only be called by an arbitration user

Parameters

NameTypeDescription
_permissionDomainIduint256The domainId in which the extension has the arbitration permission
_childSkillIndexuint256The index that the _domainId is relative to _permissionDomainId
_callerPermissionDomainIduint256The domainId in which the caller has the arbitration permission
_callerChildSkillIndexuint256The index that the _domainId is relative to _callerPermissionDomainId
_expenditureIduint256The id of the expenditure
_punishboolWhether the staker should be punished by losing an amount of reputation equal to the stake

cancelAndReclaimStake(uint256 _permissionDomainId, uint256 _childSkillIndex, uint256 _expenditureId)

Can only be called by expenditure owner while expenditure is in draft state

Parameters

NameTypeDescription
_permissionDomainIduint256The domainId in which the extension has the arbitration permission
_childSkillIndexuint256The index that the _domainId is relative to _permissionDomainId
_expenditureIduint256The id of the expenditure

deprecate(bool _deprecated)

Called when deprecating (or undeprecating) the extension

Parameters

NameTypeDescription
_deprecatedboolIndicates whether the extension should be deprecated or undeprecated

executeMetaTransaction(address _user, bytes memory _payload, bytes32 _sigR, bytes32 _sigS, uint8 _sigV):bytes returnData

Main function to be called when user wants to execute meta transaction. The actual function to be called should be passed as param with name functionSignature Here the basic signature recovery is being used. Signature is expected to be generated using personal_sign method.

Parameters

NameTypeDescription
_useraddressAddress of user trying to do meta transaction
_payloadbytesFunction call to make via meta transaction
_sigRbytes32R part of the signature
_sigSbytes32S part of the signature
_sigVuint8V part of the signature

Return Parameters

NameTypeDescription
returnDatabytesReturn data returned by the actual function called

finishUpgrade()

A function to be called after an upgrade has been done from v2 to v3.

Note: Can only be called by the colony itself, and only expected to be called as part of the upgrade() call. Required to be external so it can be an external call.

getCapabilityRoles(bytes4 _sig):bytes32 roles

Gets the bytes32 representation of the roles authorized to call a function

Parameters

NameTypeDescription
_sigbytes4The function signature

Return Parameters

NameTypeDescription
rolesbytes32bytes32 representation of the authorized roles

getColony():address colony

Gets the address of the extension's colony

Return Parameters

NameTypeDescription
colonyaddressThe address of the colony

getDeprecated():bool deprecated

Gets the boolean indicating whether or not the extension is deprecated

Return Parameters

NameTypeDescription
deprecatedboolBoolean indicating whether or not the extension is deprecated

getMetatransactionNonce(address userAddress):uint256 nonce

Gets the next metatransaction nonce for user that should be used targeting this contract

Parameters

NameTypeDescription
userAddressaddressThe address of the user that will sign the metatransaction

Return Parameters

NameTypeDescription
nonceuint256The nonce that should be used for the next metatransaction

getStake(uint256 _expenditureId):Stake stake

Get the stake for an expenditure

Parameters

NameTypeDescription
_expenditureIduint256The id of the expenditure to get the stake for

Return Parameters

NameTypeDescription
stakeStakeThe stake, a struct holding the staker's address and the stake amount

getStakeFraction():uint256 _stakeFraction

Get the stake fraction

Return Parameters

NameTypeDescription
_stakeFractionuint256The stake fraction

identifier():bytes32 _identifier

Returns the identifier of the extension

Return Parameters

NameTypeDescription
_identifierbytes32The extension's identifier

initialise(uint256 _stakeFraction)

Initialise the extension

Parameters

NameTypeDescription
_stakeFractionuint256WAD-denominated fraction, used to determine stake as fraction of rep in domain

install(address _colony)

Configures the extension

Parameters

NameTypeDescription
_colonyaddressThe colony in which the extension holds permissions

makeExpenditureWithStake(uint256 _permissionDomainId, uint256 _childSkillIndex, uint256 _domainId, bytes memory _key, bytes memory _value, uint256 _branchMask, bytes32[] memory _siblings)

Make an expenditure by putting up a stake

Parameters

NameTypeDescription
_permissionDomainIduint256The domainId in which the extension has the administration permission
_childSkillIndexuint256The index that the _domainId is relative to _permissionDomainId,
_domainIduint256The domain where the expenditure belongs
_keybytesA reputation hash tree key, of the total reputation in _domainId
_valuebytesReputation value indicating the total reputation in _domainId
_branchMaskuint256The branchmask of the proof
_siblingsbytes32[]The siblings of the proof

multicall(bytes[] calldata _data):bytes[] results

Call multiple functions in the current contract and return the data from all of them if they all succeed

Note: The msg.value should not be trusted for any method callable from multicall.

Parameters

NameTypeDescription
_databytes[]The encoded function data for each of the calls to make to this contract

Return Parameters

NameTypeDescription
resultsbytes[]The results from each of the calls passed in via data

owner():address owner

Get the owner of the contract

Return Parameters

NameTypeDescription
owneraddressThe owner of the contract

reclaimStake(uint256 _expenditureId)

Reclaims the stake if the expenditure is finalized or cancelled

Parameters

NameTypeDescription
_expenditureIduint256The id of the expenditure

setOwner(address owner_)

Set the owner of the contract

Parameters

NameTypeDescription
owner_addressThe new owner of the contract

setStakeFraction(uint256 _stakeFraction)

Sets the stake fraction

Parameters

NameTypeDescription
_stakeFractionuint256WAD-denominated fraction, used to determine stake as fraction of rep in domain

uninstall()

Called when uninstalling the extension

verify(address _user, uint256 _nonce, uint256 _chainId, bytes memory _payload, bytes32 _sigR, bytes32 _sigS, uint8 _sigV):bool bool

Verifies the signature for the metatransaction

Parameters

NameTypeDescription
_useraddressAddress of user trying to do meta transaction
_nonceuint256Nonce of the user
_chainIduint256Chain id where the signature is valid for
_payloadbytesFunction call to make via meta transaction
_sigRbytes32R part of the signature
_sigSbytes32S part of the signature
_sigVuint8V part of the signature

Return Parameters

NameTypeDescription
boolboolindicating if the signature is valid or not

version():uint256 colonyVersion

Get the Colony contract version. Starts from 1 and is incremented with every deployed contract change.

Return Parameters

NameTypeDescription
colonyVersionuint256Version number