I am currently trying to build a prototype for a simple Ethereum based Ebay - I know there are already solutions for it, it is just for learning purposes.
Currently I am lacking the understanding on how to pass in changing ether values into functions. For example when I want to post a new auction:
struct Auction{
address owner;
uint price;
string describtion;
}
Auction[] public auctions;
function createAuction(address _owner, uint256 _price, string _describtion) public{
Auction memory _auction = Auction({
owner: _owner,
price: _price,
describtion: _describtion
});
auctions.push(_auction);
}
This is the output of an example auction in remix after calling the getter of the auctions array:
When I am now adding a new auction, I can only hand it uint256 values, which makes the prices non-ether values. My question is, how can I let the function know that the price variable is of type ether?
PS. I tried to create a static global variable, which is of type ether and it gives me back the ether value in wei. But I still can't adapt this on how to give the function different ether values with each call.
uint256 public auctionStartPrice = 0.015 ether;
struct Auction{
address owner;
uint256 price;
string describtion;
}
Auction[] public auctions;
function createAuction(address _owner, string _describtion) public{
Auction memory _auction = Auction({
owner: _owner,
price: auctionStartPrice,
describtion: _describtion
});
auctions.push(_auction);
}
function getVAlueOfAuction(uint256 x) public returns (uint256 value){
value = auctions[x].price;
return value;
}
Here is the output with the global variable as starting price: