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:
- Pens - My bag runneth over with pens. Really, I'm fine, I don't nee any more. Also, if you must make that your swag, don't make me 'work' for a pen. Really? I'm not going to sit through a session about hybridized lizards in the cloud for your crummy mass ordered pens.
- Buttons - If the button is made of money, and doesn't have a pin in the back, and it's actually just a $5 bill, then yeah, sure. Other than that? Big nope.
- Poor quality shirts or outright badly designed shirts - I know what I'm talking about here. Give me a shirt that YOU'D like to wear, and I don't mean just because you work there. Also - when you hand me a shirt that's made out of tissue paper thin material, it's like "Hey, let's not kid each other - you're just going to turn this thing into a rag."
- Four words - Fun Size Candy Bars - If you do this, I hate you on sight. You didn't plan ahead and ended up hitting Target on your way from the airport. Just because vendor halls are like Halloween trick-or-treating doesn't mean you have to handle it that way. Shame on you and your company for dialing that one in.
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!