Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
erasure-contracts
Advanced tools
Contracts for Erasure, a decentralized marketplace for data feeds and predictions
A decentralized marketplace for data feeds and predictions
This repo assumes you have truffle installed globally. If you don't have it make sure you have the most recent version installed.
yarn global add truffle
truffle version
Truffle v4.1.7 (core: 4.1.7)
Solidity v0.4.23 (solc-js)
Install packages using yarn
yarn
Start a local blockchain like Ganache. You can use Ganache CLI or the desktop client.
yarn run ganache
Compile and migrate your local smart contracts.
truffle migrate --reset
yarn run ganache
yarn run test
There are 3 main contracts:
The exact details of the token spec is TBD. But fundamentally, ERASE will be a burnable and mintable ERC20 contract.
createMessage(uint256 nonce, string ipfsHash, uint256 revealedBy)
revealMessage(uint256 nonce, bytes32[] secret)
event MessageCreation(uint256 nonce, address creator);
event MessageReveal(uint256 nonce);
configureMinimumStake(uint256 minimumStake)
=> updates minimumStake during the configuration phase of the contractconfigureGriefingRatio(uint256 stakeRatio)
=> updated griefingRatio (used for griefing) during the configuration phase of the contractconfigureGriefingPeriod(uint256 griefingPeriodInWeeks)
createFeed(uint256 stakeToCreate, uint256 feePerPrediction)
cancelFeed(uint256 feedId)
=> can only be called if the feed doesn't have a buyer or if the feed is not in a griefing period. This also returns the seller stake.endBuyerSellerRelationship(uint256 feedId)
=> can only be called by the seller or buyer. Unsets the buyer. 2 weeks following this, buyer or seller can slash stakes.stakeToBuyFeed(uint256 feedId, uint256 stakeToBuy)
=> sets buyerAddress and escrows the stake, can only be called if buyerAddress of a given feed is unsetgriefBuyer(uint256 feedId, address buyer, uint256 amount)
, can only be called by the seller for a specific feed within 2 weeks of ending relationshipgriefSeller(uint256 feedId, uint256 amount)
, can only be called by the buyer for a specific feed within 2 weeks of ending relationshipupdateFeePerPrediction(uint256 feedId, uint256 feePerPrediction)
=> only if feed doesn't have a buyer.withdrawBuyerStake(uint256 feedId)
=> after the griefing period is over, the buyer can withdraw the leftover stake from the contractcreatePrediction(uint256 feedId, uint256 nonce, string ipfsHash, uint256 revealedBy)
=> calls the Erasure contract to create the corresponding message object.revealPredictionToBuyer(uint256 predictionId, bytes32[] buyerSecret)
revealPredictionToPublic(uint256 predictionId, bytes32[] publicSecret)
=> calls the Erasure contract to update the secret
of the corresponding message object.purchasePrediction(uint256 predictionId)
createUser(string publicKey)
=> Adds an address/publicKey pair to userAddressToPublicKey mapping, only for new Ethereum addresses.event BuyerStakeWithdrawal(address buyer, uint256 buyerStake);
event FeedBuyerRemoval(uint256 feedId, address seller, address oldBuyer, address actor);
event FeedCancellation(uint256 feedId, address seller);
event FeedCreation(uint256 feedId, address seller);
event FeedFeePerPredictionUpdate(uint256 feedId, address seller, uint256 feePerPrediction);
event FeedPurchase(uint256 feedId, address seller, address buyer);
event GriefByBuyer(address buyer, address seller, uint256 buyerStake, uint256 sellerStake);
event GriefBySeller(address buyer, address seller, uint256 buyerStake, uint256 sellerStake);
event PredictionBuyerReveal(uint256 feedId, uint256 predictionId, address seller, address buyer);
event PredictionCreation(uint256 feedId, uint256 predictionId, address seller);
event PredictionPublicReveal(uint256 feedId, uint256 predictionId, address seller);
event PredictionPurchase(uint256 feedId, uint256 predictionId, address seller, address buyer);
event UserCreation(address userAddress, string publicKey);
approveAll(address spender)
=> Sets the allowance from msg.sender to spender to 2 ^ 256 - 1transferFrom(address from, address tto, uint value)
=> Modified version of the standard transferFrom. If the allowance is equal to 2 ^ 256 - 1, it doesn't adjust the allowance post transferevent ApproveAll(address sender, address spender);
event TestingBuyTokens(address account, uint256 amount);
event TestingDistributeTokens(address account, uint256 amount);
event TestingReturnTokens(address account, uint256 amount);
uint64
for IDs, while most standard Ethereum apps seem to use uint256
, is that a problem?To deploy to rinkeby or mainnet, first configure your environment.
Generate a MNEMONIC using Metamask and get an API key from Infura
Make sure your account (the first address derived from your MNEMONIC) has at least 0.7 ETH
, then run
MNEMONIC="your mnemonic" INFURA_API_KEY="your API key" yarn run migrate:rinkeby
# or
MNEMONIC="your mnemonic" INFURA_API_KEY="your API key" yarn run migrate:mainnet
FAQs
Contracts for Erasure, a decentralized marketplace for data feeds and predictions
The npm package erasure-contracts receives a total of 1 weekly downloads. As such, erasure-contracts popularity was classified as not popular.
We found that erasure-contracts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.