My solidity "0.7.0" contract
pragma solidity ^0.7.0;
contract DoubleEscrowTrade {
uint256 private locked = 2; //2: unlocked, 1: locked. uint256 is gas efficient than bool
uint256 public value=0; //poster value
uint256 public bidItemValue=0; //bidder item value
bool public openForBid = false; //allow items with any value to bid.
string public posterItemName;
string public whoInitDispute;
uint256 public posterItemID;
string public bidderItemName; //no string array supported
uint256 public bidderItemID;
mapping (address=>address) public bidItemAddress; // bidder address and bidder item deploy address
mapping (address=>uint256) public bidItemID;
mapping (address=>uint256) public bidValue;
mapping (address=>string) public bidItemName;
uint256 public howManyBidItem=0;
address payable public poster;
address payable public bidder;
bool public delisted = false;
bool public posterDispute = false;
bool public bidderDispute = false;
bool public posterShipped = false;
bool public bidderShipped = false;
uint256 public posterReceiveProdTime = 0;
uint256 public bidderReceiveProdTime = 0;
uint256 public posterReceiveReturnTime = 0;
uint256 public bidderReceiveReturnTime = 0;
uint256 public posterAcceptBidTime = 0;
uint256 public posterEscrowBalance = 0;
uint256 public posterEscrowRefund = 0;
uint256 public bidderEscrowBalance = 0;
uint256 public bidderEscrowRefund = 0;
uint256 public bidderShipProdTime = 0;
uint256 public posterShipProdTime = 0;
uint256 public posterDepositTime = 0;
uint256 public bidderDepositTime = 0;
uint256 public posterDisputeTime = 0;
uint256 public bidderDisputeTime = 0;
uint256 public posterDelistTime = 0;
uint256 private graceDay = 14;
uint256 private dayInSecond = 24*3600;
enum State { ForTrade, PosterAcceptBid, PosterEscrowDeposited, BidderEscrowDeposited, PosterDelisted, BidderCancelled, BidderShipped, PosterShipped,
InDispute, Complete, PosterReceiveProduct, PosterReceiveReturn, BidderReceiveProduct, BidderReceiveReturn }
State public state;
The public variables include address, mapping, uint256, string and bool. The app can get value for a public variable myVar
with myContract.myVar()
. However there will be excessive number of requests with so many variables and it is tedious as well. Based on my reading, I probably can get all uint256 variables with return (var1, var2, ... varN) in an array. But I am not sure if mapping, bool, string and address can be all returned within one return in solidity 0.7.0. Or there is a even better way to handle this.