current position:Home>Remix compilation error
Remix compilation error
2022-02-03 23:19:02 【Q & A of Denglian community】
pragma solidity ^0.4.16;contract DataTradingModeSC{bool public scstatus;address public owner;string public DTCName;uint public numberOfDOs;mapping (address => uint) public dataownerId;DO[] public dataowners;string public IPFSHash;//the ipfs hash of the data trading agreementaddress public ABRaddress;address public DSSPaddress;address public DOaddress;
string public dataname;enum contractStatus{ WaitingforDP, Terminated}contractStatus public status;enum DPStatus{DPPaid, DODeposited, DPReceivedHashandToken, DownloadConfirmedbyDSSP,SuccessfulTrading, CannotDownload, DataUnavailable,TradingCompleted, Refunded}uint public numberOfDPs;
uint public timeliness = 7;//7 daysuint public dataprice;string public datastoragehash;//the ipfs hash of the data storagemapping (address => DP) public datapurchasers;
event DOAdded(address DataOwnerAddress, string DataProduct, string DataNotes);event DORemoved(address DOAddress);event StatusChanged(string Status);event DPPaid(address datapurchaser, string info); event DODeposited(string info,address datapurchaser);event tokenGeneratedforDP(address datapurchaser, bytes32 token, uint timestamp, uint duration);event DPDownloadedDatafromDSSP(address datapurchaser, string info);event successfulTrading(address datapurchaser);event unsuccessfulTradingDPCannotDownload(address datapurchaser, string info);event unsuccessfulTradingDPDataUnavailable(address datapurchaser, string info);event ABRIsVerifyingforDP(address datapurchaser, string info, bytes32 token);event refundDone(address datapurchaser);event DPCouldNotDownload(address datapurchaser, string info);event DPDataUnavailable(address datapurchaser, string info); event paymentSettled(address datapurchaser, string info);event refundBasedonDPRequest(string info, address datapurchaser);struct DO { address dataowner; string dataproduct; string datanotes; uint dataownerSince;}struct DP { DPStatus status; int result; bytes32 token; }modifier OnlyOwner { require (msg.sender == owner); _;}modifier NotOwner(){ require(msg.sender != owner); _;}modifier OnlyDSSP(){ require(msg.sender == DSSPaddress); _;}modifier NotDSSP(){ require(msg.sender != DSSPaddress); _;}modifier OnlyABR(){ require(msg.sender == ABRaddress); _;}modifier NotABR(){ require(msg.sender != ABRaddress); _;}modifier NotDO(){ require(msg.sender != DOaddress); _;}modifier DPPayment(){ require(msg.value == dataprice); _;} modifier DODeposit(){ require(msg.value == dataprice); _;} //function DataTradingModeSC(string enterDTCName, string dataName) public { constructor (string enterDTCName, string dataName) public { owner = 0xd813351258D8A53314E55b12c3Cf11C98dA8E7D4; DSSPaddress = 0x380851065aBf6F833eFBE9e059aF9D2F31baCD54; ABRaddress = 0xd06B32822f5F1838E0Bb05CBEC803889eFDd9380; DOaddress = 0x09BdFdBAc10253e988b4c7197f0faf44Ea7F8479; //DPaddress = 0x9549E34316ab06B205711B2eF1Ea5D078C6e8E5f; dataprice = 3 ether; datastoragehash = "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH"; IPFSHash = "QmPvqGheEUnHdacVPoL69KMnkNsQUCvxQ5SF8cfmZkHuQg"; scstatus = true; addDO(0,"",""); DTCName = enterDTCName; dataname = dataName; numberOfDOs = 0; numberOfDPs = 0; }function changeSmartContractStatus (bool deactivate) OnlyOwner public { if (deactivate) {scstatus = false;} emit StatusChanged ("The smart contract deactivated.");}function addDO (address dataOwnerAddress, string dataProduct, string dataNotes) OnlyOwner public { require (scstatus = true); uint id = dataownerId[dataOwnerAddress]; if (id == 0) { dataownerId[dataOwnerAddress] = dataowners.length; id = dataowners.length++;} dataowners[id] = DO ({dataowner: dataOwnerAddress, dataownerSince: now, dataproduct: dataProduct, datanotes: dataNotes}); emit DOAdded (dataOwnerAddress, dataProduct, dataNotes); numberOfDOs++;}function removeDO (address dataOwnerAddress) OnlyOwner public { require (dataownerId[dataOwnerAddress] != 0); for (uint i = dataownerId[dataOwnerAddress]; i < dataowners.length-1; i++){ dataowners[i] = dataowners[i+1];} delete dataowners[dataowners.length-1]; dataowners.length--; emit DORemoved(dataOwnerAddress); numberOfDOs--;} function RequestGetData() NotOwner NotDSSP NotABR NotDO DPPayment public payable{//only the data purchaser require(status == contractStatus.WaitingforDP); datapurchasers[msg.sender].status = DPStatus.DPPaid; emit DPPaid(msg.sender, "The data purchaser has paid for the data price."); numberOfDPs++;} function payDeposit(address datapurchaser) DODeposit public payable{//the data owner pay the trading deposit require(msg.sender == DOaddress); if(datapurchasers[datapurchaser].status == DPStatus.DPPaid){ emit DODeposited("Trading with the data purchaser", datapurchaser); datapurchasers[datapurchaser].status = DPStatus.DODeposited; generateDownloadDataToken(datapurchaser, timeliness); } } function purchaserRefund()NotABR NotDSSP NotOwner NotDO public payable{ //only the data purchaser require(datapurchasers[msg.sender].status == DPStatus.DPPaid); uint x = dataprice; msg.sender.transfer(x); datapurchasers[msg.sender].status = DPStatus.Refunded; emit refundBasedonDPRequest("The data purchaser has been refunded.", msg.sender);}function generateDownloadDataToken(address datapurchaser,uint Timeliness) internal{ //the smart contract internal call require(datapurchasers[datapurchaser].status == DPStatus.DODeposited); bytes32 token = keccak256(abi.encodePacked(datapurchaser,DOaddress,owner,dataname,block.timestamp,Timeliness));//the unique token for each data purchaser //bytes32 token = abi.encodePacked(datapurchaser,DOaddress,owner,dataname,block.timestamp,Timeliness);//the unique token for each data purchaser datapurchasers[datapurchaser].token = token; emit tokenGeneratedforDP(datapurchaser, token, block.timestamp, timeliness); datapurchasers[datapurchaser].status = DPStatus.DPReceivedHashandToken;//the data purchaser received the hash and token }function sendDownloadedInformation(address datapurchaser) OnlyDSSP public payable{ //the data purchaser has downloaded the data require(datapurchasers[datapurchaser].status == DPStatus.DPReceivedHashandToken); emit DPDownloadedDatafromDSSP(datapurchaser, "The data purchaser has done download."); datapurchasers[datapurchaser].status = DPStatus.DownloadConfirmedbyDSSP;}function DPComfirmedResult(int result) NotDSSP NotABR NotOwner NotDO public{//only the data purchaser require (datapurchasers[msg.sender].status == DPStatus.DownloadConfirmedbyDSSP); if(result == 1)//1 represents a successful trading { emit successfulTrading(msg.sender); datapurchasers[msg.sender].status = DPStatus.SuccessfulTrading; settlementAndPayment(msg.sender); } else if(result == 2){//2 represents the data purchaser can not download controversy emit unsuccessfulTradingDPCannotDownload(msg.sender,"The data can not download."); datapurchasers[msg.sender].status = DPStatus.CannotDownload; emit ABRIsVerifyingforDP(msg.sender, "Token: ", datapurchasers[msg.sender].token); } else if(result == 3){//3 represents the data is unavailable controversy emit unsuccessfulTradingDPDataUnavailable(msg.sender, "The data is inconsistent with its description"); datapurchasers[msg.sender].status = DPStatus.DataUnavailable; emit ABRIsVerifyingforDP(msg.sender, "Off-chain testing data and Token: ", datapurchasers[msg.sender].token); }}function downloadControversyResolutionAndPayment(address datapurchaser, bool arbitrationResult) OnlyABR public payable{//the data download controversy resolution require(datapurchasers[datapurchaser].status == DPStatus.CannotDownload); if(arbitrationResult){//data cannot download emit DPCouldNotDownload(datapurchaser, "The data purchaser should be refunded."); uint x = dataprice; datapurchaser.transfer(x);//refund the data purchaser DOaddress.transfer(x);//refund the data owner emit refundDone(datapurchaser); datapurchasers[datapurchaser].status = DPStatus.TradingCompleted; } else{//the data can be downloaded emit successfulTrading(datapurchaser); datapurchasers[datapurchaser].status = DPStatus.SuccessfulTrading; settlementAndPayment(datapurchaser); }}function availabilityControversyResolutionAndPayment(address datapurchaser, bool arbitrationResult) OnlyABR public payable{//the data availability controversy resolution require(datapurchasers[datapurchaser].status == DPStatus.DataUnavailable); if(arbitrationResult){//the data is unavailable emit DPDataUnavailable(datapurchaser, "The data purchaser should be refunded and compensated."); uint x = dataprice; datapurchaser.transfer(x*2);//refund and compensate the data purchaser emit refundDone(datapurchaser); datapurchasers[datapurchaser].status = DPStatus.TradingCompleted; } else{//the data is available emit successfulTrading(datapurchaser); datapurchasers[datapurchaser].status = DPStatus.SuccessfulTrading; settlementAndPayment(datapurchaser); }}function settlementAndPayment(address datapurchaser) internal{//the smart contract internal call require(datapurchasers[datapurchaser].status == DPStatus.SuccessfulTrading); uint x = dataprice/3; DSSPaddress.transfer(x); //pay the data storage service provider owner.transfer(x); //pay the data trading center DOaddress.transfer(x+x*3); //pay the data owner and return deposit emit paymentSettled(datapurchaser, "Payment and settlement has done successfully."); datapurchasers[datapurchaser].status = DPStatus.TradingCompleted;}
}
The above is the code part of the contract , Click on deploy An error occurred when , The following tips are given :
VM error: revert.revert The transaction has been reverted to the initial state.Note: The constructor should be payable if you send value. Debug the transaction to get more information.
Take the answer 1:
constructor (string enterDTCName, string dataName) public {owner = 0xd813351258D8A53314E55b12c3Cf11C98dA8E7D4;
You're going to put this owner Change to your own address . I compiled it , Deployment is OK . Pay attention to its error report .
Other answers 1:
copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032319002522.html
The sidebar is recommended
- How to find blockchain teachers?
- In solidity_ What do you mean?
- Can flutter be used
- Learning aggregate signature information
- Can a solid contract implement a method at a fixed point in time every day
- Excuse me? How does Ethereum obtain a certain number of transactions
- Use openzeppelin to deploy contracts that can be upgraded. How do you see the address of your contract after deployment? You can only see the contracts of openzeppelin systems in the browser?
- After calling mycontract methods. myfunction(a,b). Send() reports an error
- What does the public key of the transaction in the blockchain mean?
- How to build an etc node
guess what you like
-
Can the solidness contract be debugged in one step like ordinary code?
-
How to implement the GSN method that users can execute the contract without handling charges
-
Real project, pay for help: want to learn how to get money on decentralized exchanges such as uniswap!
-
An error occurs when truffle compiles sol files
-
Truffle compilation error type (c) Creationcode compilation failed
-
How does smart contract use oracle
-
The execution process of smart contract is too long
-
Error: invalid JSON RPC response: typeerror: t is not a function
-
Use the openzeppelin part to see an upgradeable contract. In the business contract part, NPX oz Verigy has always failed to verify. It has been successful before. By comparison, it can only be caused by a large amount of code,
-
web3. How to handle the cross domain of JS link test chain
Random recommended
- How does Ethereum keep sending transactions
- Deploying scalable contracts with openzeppelin doesn't consume much gas limit in repsten network. Why is it so high in mainnet? It has failed all the time
- Truffle cannot download the version specified by the Solc compiler
- How to develop Ethereum smart wallet?
- Is there a way for golang to monitor eth transfer?
- Address (uint160 (users [beneficial_eth_finish]) is executed in the smart contract An error is reported when transfer() transfers eth to an address
- The gas limit for deploying smart contract has been set to 800W, which is the largest. What should I do if it is insufficient,
- The problem of transferring eth to other contracts in the contract?
- Using for loop in smart contract may consume gas, but is there a better one
- How can such a set in the contract need so many gas?
- The gas limit is not enough for the problem that the contract is transferred to eth
- How does Ethereum call deployed contracts within a contract?
- Help ~ ~ ~ uniswap submit issue
- Eth contract
- There is a very long array to be traversed in the contract, such as 10 million data, but it may be changed to two in practice. Then execute this method. Will gas limit out of
- How to obtain the pending transaction of Ethereum network in real time??
- Can't the method in the contract be transferred into eth at the same time
- VM error : Invalid opcode. How to solve it
- EOS sending transaction problem
- About the code that is executed only once a day in the course time of the series of solid courses
- It involves the transfer of different public chain assets, for example, from BTC public chain to EOS smart contract. Why should we issue a non BTS relay contract in the middle of a BTS relay contract? Is it a smart contract that can't accommodate so many
- Can an eth contract method be implemented?
- ERROR: 1.13.4 is required to build Fabric and you are using . Please update go
- How do languages other than JS interact with smart contracts?
- Copy the contract code that has been deployed on the chain. When Remix deploys again, it will prompt eip170. How is the original contract deployed?
- Open a defi project with demo. Why can't you automatically connect to the wallet and get the wallet assets
- Fabric 2.0, peer lifecycle chaincode approveformyorg: error: timed out waiting for txid on all peers!
- How to parse the input data of the transaction generated when eth deploys the contract?
- ethers. The problem of token transaction in JS
- Installing the extendermint installation tool and relying on error reporting
- How to customize the currency circulation and reward mechanism based on Ethereum private chain
- How to calculate the gap velocity
- ethers. JS could not detect network (event ='nonetwork ') appears on the real machine debugging of uniapp
- How to calculate uniswap initcode hash
- Uniswap and truffle build local test chain
- How to get Merkle proof of Ethereum log
- How to calculate the value of LP token in uniswap.
- Is Remix ide not working?
- 'Migrations' -- Returned error: invalid transaction v, r, s values. Does anyone know how to solve this problem?
- The packages I downloaded directly from the truss unbox webpack cannot be deployed successfully. Do you know what the problem is