3 ms·
By the way, here's a GIF of what the buying process looks like: https://gfycat.com/BleakSimilarGermanspaniel https://gfycat.com/BleakSimilarGermanspaniel This
by shazow 9y ago
By the way, here's a GIF of what the buying process looks like:
https://gfycat.com/BleakSimilarGermanspaniel https://gfycat.com/BleakSimilarGermanspaniel
This is the part that blows my mind, it feels like magic every time.
(P.S. Thanks for your support, Chris!)
- billmalarky 9y agoPayment as part of the protocol alone will make DAPPs a game changer.
- eridius 9y agoThat GIF is neat, but I don't see your ad when I look at the page.
- drampelt 9y agoIt looks like they did it on the Rinkeby Testnet for that demo so they wouldn't have to spend real Ether.
- sturmeh 9y agoWait so how/where is the url/title/image stored? (I assume it's a url?) I notice you buy it then you later change the details?
- baby 9y agoit's stored on the blockchain, inside the transaction that calls the payable function. The setup is done in two steps: 1. you must pay for a rectangle area via the `buy` function (notice the `payable` specifier): function buy(uint _x, uint _y, uint _width, uint _height) payable returns (uint idx) { 2. then you can setup your ad via the publish function: function publish(uint _idx, string _link, string _image, string _title, bool _NSFW) { ~~~ 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: 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 Publish(_idx, ad.link, ad.image, ad.title, ad.NSFW || ad.forceNSFW); ~~~ 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.