* the cost of the area you're trying to buy is calculated as _width * _height * pixelsPerCell * weiPixelPrice
* with weiPixelPrice = 1000000000000000 and pixelsPerCell = 100
* The grid is defined as a double array of 100x100:
bool[100][100] public grid;
* The for loop checks that none of these pixels are set to true, if any pixel is then `revert` reverts any changes to the state that happened during execution. Otherwise the relevant coordinates are all set to true.
* The space is reserved under the address that send the ether (`msg.sender`). To do that, an `Ad` struct is filled with the information and it is pushed unto the state.
Ad memory ad = Ad(msg.sender, _x, _y, _width, _height, "", "", "", false, false);
idx = ads.push(ad) - 1;
* It returns an index (`Idx`) that you can use to specify the details of your ad later.
~~~
For more details in 2:
* You must pass the `index` of your reserved space as argument to the function
* It will check that your address is indeed the address which reserved the space:
require(msg.sender == ad.owner);
* It sets everything to the arguments of the function you're calling.
* An event is triggered, it is probably being listened to by the web app so that the web page can be updated live
* Looks like you can call the `publish` function over and over. Modifying your ad over and over.
* There is a `forceNSFW` function that the contract owner can use to force an ad to have the `NSFW` flag. But this can be re-modified again and again by the ad owner.
* But the owner of the contract can remove ownership of an Ad, so there's that.
* I just audited the contract and I couldn't find any vulnerability.
The setup is done in two steps:
1. you must pay for a rectangle area via the `buy` function (notice the `payable` specifier):
2. then you can setup your ad via the publish function: ~~~For more details in 1:
* the cost of the area you're trying to buy is calculated as _width * _height * pixelsPerCell * weiPixelPrice
* with weiPixelPrice = 1000000000000000 and pixelsPerCell = 100
* The grid is defined as a double array of 100x100:
* The for loop checks that none of these pixels are set to true, if any pixel is then `revert` reverts any changes to the state that happened during execution. Otherwise the relevant coordinates are all set to true.* The space is reserved under the address that send the ether (`msg.sender`). To do that, an `Ad` struct is filled with the information and it is pushed unto the state.
* It returns an index (`Idx`) that you can use to specify the details of your ad later.~~~
For more details in 2:
* You must pass the `index` of your reserved space as argument to the function
* It will check that your address is indeed the address which reserved the space:
* It sets everything to the arguments of the function you're calling.* An event is triggered, it is probably being listened to by the web app so that the web page can be updated live
~~~Notes:
* Looks like you can call the `publish` function over and over. Modifying your ad over and over.
* There is a `forceNSFW` function that the contract owner can use to force an ad to have the `NSFW` flag. But this can be re-modified again and again by the ad owner.
* But the owner of the contract can remove ownership of an Ad, so there's that.
* I just audited the contract and I couldn't find any vulnerability.