CodeSOD: Why I Hate Conference Swag (and What can be Done About it) |
Hey everyone - I'm at a conference this week I'd like to cover a WTF that I've been seeing this week - VENDOR SWAG.
Ok, if you are one of those poor souls who are always heads down in code and never attend workshops or conferences, this won't make much sense to you, but here's the deal - companies will set up a booth or a table and will pass out swag in exchange for your contact info and (possibly) a lead. To me, this is easily the dirtiest transaction one can make and rife with inequalities. Your information is super valuable - as in possibly generating thousands or millions of sales dollars. The 'gift' will be SUPER cheap by comparison.
How cheap? WELL, here are some examples:
True - I can, and certainly do, just say "no thanks" to that miniature Butterfinger swag ought be good. An equal exchange that's not more like selling your soul for a pen.
So, with that said...the solution? Enter Virtual Swag or vSwag.
This year, I participated in my first Hackathon ever and our team's theme was Blockchain. After registering we were given a while to prepare which I took advantage of to research the topic and for me, that was pretty fun (but actually we only just made a team after arriving).
The way we planned it, conference attendees can collect vSwag tokens from vendors and redeem them for swag items.
Below is the Solidity file I fudged together based heavily on the Ethereum Crowdsale example, not knowing anything before the Hackathon (hence my 'horrible' comment). Now, if you actually know what you're doing (not me) and want to contribute, the project is out on Github or if you want to skip to the good stuff (and like memes) check out the PowerPoint (*chef kiss*).
pragma solidity ^0.4.18;
/* This is horrible code. */
contract vSwag {
address public vendorName;
uint public swagGoal;
uint public amountRaised;
uint public deadline;
uint public price;
//token public tokenReward;
mapping(address => uint256) public balanceOf;
bool swagGoalReached = false;
bool vSwagClosed = false;
event GoalReached(address recipient, uint totalAmountRaised);
event SwagswagToken(address backer, uint amount, bool isContribution);
/* This creates an array with all balances */
// mapping (address => uint256) public balanceOf;
/**
* Constructor function
*
* Setup the owner
*/
function vSwagConstructor(
address ifSuccessfulSendTo,
uint swagGoalInEthers,
uint durationInMinutes,
uint etherCostOfEachToken,
address addressOfTokenUsedAsReward
) public {
vendorName = ifSuccessfulSendTo;
swagGoal = swagGoalInEthers * 1 ether;
deadline = now + durationInMinutes * 1 minutes;
price = etherCostOfEachToken * 1 ether;
balanceOf[msg.sender] = 1000; // How much swag coin you got, captain?
}
/* Send swag */
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
return true;
}
/**
* Fallback function
*
* The function without name is the default function that is called whenever anyone sends funds to a contract
*/
function () payable public {
uint amount = msg.value;
balanceOf[msg.sender] += amount;
amountRaised += amount;
transfer(msg.sender, amount / price);
emit SwagswagToken(msg.sender, amount, true);
}
modifier afterDeadline() { if (now >= deadline) _; }
/**
* Check if goal was reached
*
* Checks if the goal or time limit has been reached and ends the campaign
*/
function checkGoalReached() public afterDeadline {
if (amountRaised >= swagGoal){
swagGoalReached = true;
emit GoalReached(vendorName, amountRaised);
}
}
/**
* Decrement Swag
*
*/
function safeWithdrawal() public afterDeadline {
if (!swagGoalReached) {
uint amount = balanceOf[msg.sender];
balanceOf[msg.sender] = 0;
if (amount > 0) {
if (msg.sender.send(amount)) {
emit SwagswagToken(msg.sender, amount, false);
} else {
balanceOf[msg.sender] = amount;
}
}
}
if (swagGoalReached && vendorName == msg.sender) {
if (vendorName.send(amountRaised)) {
emit SwagswagToken(vendorName, amountRaised, false);
} else {
//something something...give back swag coin
swagGoalReached = false;
}
}
}
}
So, vendors, hear me now - steal this idea!
https://thedailywtf.com/articles/why-i-hate-conference-swag-and-what-can-be-done-about-it
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |