Airdropping on fx(hash): Tips and Tricks

By Nudoru and Abstractment

So, you have an awesome gentk on fx(hash)! Congratulations! Now you want to send copies to your supporters and fans? Here’s our quick guide on how to do it.

The end goal is to get a CSV file that we can drop into http://batch.xtz.tools and have it do the work of passing out our tokens for us. 

The CSV we’ll want to use for the batch tools site needs 3 columns: wallet IDs, fx(hash) token IDs, and quantity (1 for one per wallet). We’ve gone ahead and created this template for you to make it as easy as possible. When you click this link, it’ll require you to create a copy so that it’s your own unique copy.

Step 1 – Mint your tokens

This is the most manual and time-consuming part of the process. You need to manually mint each token that you want to airdrop. Put on a good show or some tunes to keep you occupied. Keep in mind that your transactions will fail if you try to process more than one mint within a single block. A good baseline is to wait 30 seconds between each mint or just wait for the confirmation to show on the fx(hash) page.  You can also track the Tezos blocks here if you want to move quickly. Once you’re done and they’re all signed by fx(hash), you may want to clear/refresh the metadata in your wallet so that the names and thumbnails are updated.

Step 2 – Get the token IDs

Go to your project’s page on this site: https://fxfam.xyz/YOUR_PROJECT_ID. Thanks to @zancan for creating this resource. This site uses the fx(hash) API to display a list of minted editions and the owner. We want to scrape the list of the tokens we minted from this site. 

Open up the JavaScript console and paste this script to the console.  Before hitting enter, change YOUR_fx(hash)_ID to your fx(hash) username on the fourth line of code.

let a=[]; 
document.querySelectorAll('li.token').forEach((e,i) => {
let o = e.querySelector('div.owner').innerText;
if(o === 'YOUR_fx(hash)_ID') {
let lnk = e.querySelector('div.inner a');
a.push(`${lnk.href}\n`)}}); 
console.log(a.join(''));

As an example, the project ID is 7044 in this sample below.

Voila!  Now you’ll see a list of all of the tokens you hold for this collection.  Copy and paste this list to column A on tab 2 of the Google sheet. We just need the ID number of each mint, and the google sheet will automate extracting this for you.

Note: Sometimes it doesn’t load all of the editions and you’ll need to refresh the page. Make sure that all editions have loaded before pasting the script for this step.

Step 3 – Get the list of lucky wallets

How you determine which wallets will receive an airdrop is up to you, you just need a list of them for column A of our sheet. Use tab 3 in the google sheet for these steps.

If you want to use the owners of previous projects:

  • Visit your project on https://fxcollectors.stroep.nl.  Shout out to @mknol for creating this. 
  • Enter your project ID and hit enter.  
  • Click the Owners tab. This entire page is sorted by the number of pieces in the wallet. Scroll to the very bottom of the page and you’ll find a text area of wallet addresses. This list is ordered by the number of pieces in the wallet, so if you want to airdrop to just holders of a specific number of pieces, you can compare the first on this page to determine where to cut it off.
  • Copy and paste the wallet addresses to column A of tab 3 in the Google sheet. Note: In a recent update, the number of editions is after the wallet addresses. You’ll need to manually remove this in the Google sheet.
  • You can pull wallets from multiple projects, just keep copying and pasting to the bottom of the list in the sheet.
    • If you want to remove duplicate wallets so that everyone only gets 1 airdrop, do the following: In Google sheets, select column A, then Data menu > Data cleanup > Remove duplicates.
  • How do you want to assign tokens to the wallets?  
    • Want your largest holders to get lower numbered editions?  If so, you’re done.  
    • Want everything randomized? Shuffle the list: With column A still selected, Data menu > Randomize range. Do this as many times as you want, but I usually do it 3 times for a good shuffle. 
    • Want to pick and choose which wallet gets which pieces?  Just put them in the order that you want and confirm they match on the first tab.

Step 4 – Double-check the sheet

Now, in the first tab (_final for CSV), you should have a Google sheet with 3 columns: a list of wallets, a list of your minted IDs, and a 1 beside each in column C. Make sure all of the data matches up and that columns A and C are the same lengths as column B. 

Export the list: File > Download > Comma Separated Values (.csv).  Open up your CSV to confirm you have just one tab with three columns.

Step 5 – Airdrops!

Now for some magic, thanks to the work of @pureSpider.  

  • Go to http://batch.xtz.tools and connect your wallet. 
  • Pick “fx(hash) 1.0” in the FA2 Contract drop down.
  • Upload or paste the CSV file.
  • Do a quick double-check of the data.
  • Click Send Transaction, and approve the transaction through your wallet. In a few minutes, you’ll see all of the transactions sent.

Clean Code

I’ve been programming for along time now. My first program was probably back in 5th or 6th grade when I had to get checked off on basic computer skills in elementary school. I think they were pretty progressive for 1989. It would have been as BASIC program on an Apple II and gone something like this:

10 PRINT "Hello!"
20 GOTO 10

I got into this seriously in 8th grade programming games in BASIC on the TRS-80s in the typing lab. Then moved though various lanauges (QuickBasic, Pascal, C++, Lingo, Javascript, ActionScript 0, 1 and 2) before landing where I currently am: an ActionScript 3 developer working with the Flash Platform.

Throughout all of this, I really just concentrated on syntax of the language and getting stuff done. But two years ago, I started using design patterns and looking beyond the code into the technique 9or craft) of coding. And in the past few weeks, I’ve really started thinking seriously about how bad I code and how want to code. In my freshman year of college, my first English assignment was a required paper titled: “My Writing Sucks and And Why.” Now I’m doing this mentally.

I picked up a copy of the excellent Clean Code by Robert C. Martin and have just started to read it. A few weeks from now, I fully intent to be a better programmer and look back on the code that I’ll write today and think: “What the hell was I thinking?!”

Note, I’d consider ActionScript 0 to be what ever the hell we were writing for frame scripts in Flash 4. That was painful.

On using SWCs …

So I’m pretty late to this party. Up until now, I’ve been using 2 methods for sharing assets on my Flash projects:

    1. An assets proxy that a coworker of mine wrote.
    2. Nothing. Ok this doesn’t count.

The assets proxy loads a SWF file and view elements can pull assets from it like

assetsProxy["linkageID"];

Can it get easier? This does a great job of separating content from code in a reusable way and keeping the main app SWF small, however, you have to wait for the assets SWF to load. And write a lot of boilerplate code to set it up, start it loading and listening/responding to the loaded event.

So what’s another way? Enter the SWC. ActiveTuts has a great tutorial on how to create and use them.

My scenario: I have a collection of learning interactions that have a lot of little clips in the libraries. Many of these are the same across interactions and really should be shared in some way. A lot of them also have class files associated with them since they need a little more functionality than a basis extended Sprite.

These classes were mixed in with my project classes and this created a special case with using a SWC: You have to set it up so that the classes are imported from the SWC instead of the class file in the project folder. It took me a few hours to figure this out – classes specific to assets in your SWC file must not be in the class path of the project file.

So I created a separate directory for all classes needed for my assets SWC and it all started working. For now, I just dumped it all in the lib folder because I can’t think of a better place. The project classes are safely in the src folder, nice and separate.

With this SWC linked in FDT and the SWC added to the library path of the FLA this is a quick snip of my code:

package screen
{
	// this class is in the SWC, need to import
	import assets.view.WheelList.WheelListItemSprite;

	// stuff

	private function drawList():void
	{
		// stuff
		var item:WheelListItemSprite = new WheelListItemSprite();
		// stuff
	}
}

The library of my interaction FLA went from over 10 clips to none. And they're all separated and ready for reuse in other interactions.

Nori Bindable Model

Here’s the super simple bindable model class that I’ve created for Nori. I’ve never actually developed a project with Flex, but I really like the idea behind it’s data binding implementation. I tried to create something similar for Flash/AS3.

package com.nudoru.nori.model 
{
	import flash.utils.Dictionary;
	import org.osflash.signals.Signal;
	import com.nudoru.nori.model.bind.PropertyChangedVO;

	/**
	 * Adds data binding functionality to the abstract model
	 * Usage:
	 * 
	 * 	To set up a property to be bound:
	 * 		public function set bind_prop(value:String):void
	 * 		{
	 * 			bind_prop_field = value;
	 * 			dispatchPropertyChange("bind_prop", bind_prop_field [, old_value]);		// this is the important line
	 * 		}
	 * 	
	 * 	To bind the property:
	 * 		bindable_model.bindProperty("bind_prop", binding_listener_function);	
	 * 		bindable_model.bindtest = "hello!";
	 * 	
	 * 	The binding_listener_function may any function and as long as it takes the new property value as an argument
	 * 
	 * This class should be subclassed to create more enhanced functionality.
	 */
	public class BindableModel extends AbstractModel implements IBindableModel
	{	

		/**
		 * Signal for simple binding
		 */
		protected var _onPropertyChangeSignal	:Signal = new Signal(PropertyChangedVO);

		/**
		 * Map of the bindings
		 */
		protected var _bindingMap				:Dictionary = new Dictionary(true);

		public function get onPropertyChangeSignal():Signal
		{
			return _onPropertyChangeSignal;
		}

		/**
		 * Binds a function to a property name
		 * @param propName Name of the property
		 * @param setter Function to call when the property changes. Must take the property's value as a param
		 * @param overwrite Will remove existing setters and assign a new one
		 */
		public function bindProperty(propName:String, setter:Function, overwrite:Boolean = false):void
		{
			if(overwrite) unbind(propName);
			
			if(!isPropertyBound(propName))
			{
				_bindingMap[propName] = setter;
			}
			// if the signal doesn't have any listeners yet, set it up
			if(onPropertyChangeSignal.numListeners < 1)
			{
				onPropertyChangeSignal.add(handlePropertyChanged);
			}
		}

		/**
		 * Remove the bindings for a property
		 */
		public function unbind(propName:String):void
		{
			if(isPropertyBound(propName))
			{
				delete _bindingMap[propName];
			}
		}

		/**
		 * Determins if the property is bound to anything
		 */
		protected function isPropertyBound(propName:String):Boolean
		{
			return (_bindingMap[propName]) ? true : false;
		}

		/**
		 * Called from a setter to notify bindings of a change to the value
		 */
		protected function dispatchPropertyChange(name:String, value:*, oldvalue:*=undefined):void
		{
			if(isPropertyBound(name))
			{
				var vo:PropertyChangedVO = new PropertyChangedVO(name, value, oldvalue);
				onPropertyChangeSignal.dispatch(vo);	
			}
			
		}

		/**
		 * Listener for the onPropertyChangeSignal signal and notifys bound setter
		 */
		protected function handlePropertyChanged(changeObject:PropertyChangedVO):void
		{
			if(isPropertyBound(changeObject.name))
			{
				var func:Function = _bindingMap[changeObject.name]as Function;
				func.call(this, changeObject.value);
			}
		}

		/**
		 * Construtor
		 */
		public function BindableModel() 
		{
			super();
		}

	}
}

Nori Framework

Lately, I’ve been into learning new things – one of them has been to find out what IOC (Inversion of Control) and DI (Dependency Injection) is all about. As a working project for this, I’ve taken the Cairngorm based framework that I created at work and started to do a major rewrite around IOC. I’m basing most of it on Robotlegs.
Not much to say right now, but I’ll toss up information about it and informative links that I’ve found soon.

Social sim. engine, Part 3 – Progress!

Thanks to a wonderful confluence of events and great timing, I’m able to turn this in to a project for work – there are a handful of solutions in the queue that can use this starting next month – so I’m working full time on it over the month of Feburay.

After a few days, this is what I’ve got: click. It’s a pretty straight forward scenario, but it demonstrates all of the features that I’ve got working.

I’ve been able to keep up with my “play” metaphor and it’s working out great by providing many more opportunities for gaming rather than typical multiple choice branching.

One of the projects brought up a requirement that started a new idea – an inventory system. All I really need to do is allow the learner to reference a screen shot to get some data, but I think it can be taken farther. But more on that later.

Designing learning interactions that no one wants to use

Well, done that!

Multiple Sliders

I had a requirement to for an interaction for learners to rate up to six criteria for a given scenario. I thought of 3 different ways to do it: 1) that, 2) text entry and 3) drop down menus.

Text entry was the first idea. But that’s commonplace – can you call that an idea? I had a slider component that I’d coded for a project a year ago that was never used – so why not? The result, while interesting, fails miserably on many levels with visual clutter being the main one. I still think that it would work for up to 3 or 4 items, but it just doesn’t for this many.

So go back and do something more simple – with drop downs. I’d coded the slider to use the same basic properties as the native AS3 ones so, there wasn’t that much more effort to make this change. It’s much easier for the learner to use and saves a lot of space – so much that the scenario can be on the same screen as the question.

Created a few learning interactions today

When I started Ramen, one of the goals was to allow the page templates/interactions to be used outside of the system – in a Lectora course for example. This has even become more important as my day job standardizes on Lectora as the shell for any tracked learning content. Over the past year, I’ve been able to write a whole lot of really easy to use APIs for creating learning interactions. Creating a new interaction takes just a few hours using the Ramen page template API and borrowing functionality from existing templates.

The biggest benefit of this is quick and easy reusability. Just change the XML file and it’s a new page. I don’t want to even think about how hard  some of these would be to pull of in Lectora. It gets really confusing when the action icons start to pile up.

I’m helping out on a project now that needs a few learning interactions developed – quickly. So I spent today working on these. Here they are in the Ramen player:

These aren’t the fanciest interactions ever created, but not bad for a few hours work.

Rethinking the Social Simulation

So far, I’ve gotten a basic schema defined for the structure file and a good start on most of the base data classes.

I’ve been planning to go down the most familiar path: a page-branch-page-branch-etc. architecture/flow. It’s the one that any elearning developer would be most familiar with. Each page contains pictures of the people and if it’s an interaction a few choices to click on. Just repeat that over and over and you have it. It’s a fairly “dumb” system.

But then I had a new idea on how to make this thing operate … had to dig out my Moleskine and start taking notes (for the first time in nearly 2 years).

What’s a better metaphor for this thing? How about a play? In this case my characters are actors. And what about all of the text? It’s generated from the actors! What about logic – is it in the page interaction or the controller? No – it comes from the actors reacting to a spoken line from another character.

Probably a small thing – but in the scope of what I want to do – it’s ground breaking. Now we have persistent actors on the stage (which now really is a stage) who drive the dialog and their reaction to it. Pages are now the “script” that is fed to the actors and look/feel of each page is the “set.” We don’t have a dumb template system we have a set of intelligent programmable avatars.

In code, each actor will be a component in the library following a MVC model. The sim. engine controller will handle the event listening and dispatch it to the correct actor. The logic will be part XML defined and part variable driven and will be in the actor’s controller. The look of the actor will be driven by logic (change based on emotion/score!) and the appearance of the dialog will come from the actor. Any narrative text (instructions, etc.) would be narration driven by the engine/narrator character. Interaction on a spoken line will cause a reaction in the targeted actor (you could speak to the mentor!) and will direct the play to a new page in the script. The page script will control the actor’s position, the look of the set, and feed new dialog to the actors.

This tips the possibilities towards the complex end of the scale – more complicated scenarios will be easier to play out while a linear scenario would be more difficult. It also opens the door towards making it more of a game. Actors can have different personalities by tweaking their logic and their automatic reactions. Point modifiers for certain actors and certain lines. Maybe you could flirt with the other actor. Maybe you could ask the mentor for help – or earn a “smooth talking” bonus? I’m thinking of a lot of new ideas here …

Social sim. engine, pt. 2

So what’s first? I’ve got the requirements down, so now I need to start translating that in to code.

The most basic thing I’ll need to build is a player. I like to use a simple MVC pattern for this. It’ll need to be a very scaled down version of my Ramen player so that should be easy enough.

The player/controller will have the model load an XML file that contains the information for the characters, the structure of the sim and some settings (ui, speed, don’t know at this point). Model will do a little parsing and then the view will take over and draw the UI. After we’re all set up, the player will show the first page.

Each page will be a movie clip in the library of the player. In ramen, each page is an external SWF, but I’d like to keep this player simple. Having everything in one place will make it easier to keep a consistent UI and make it easier to edit. The content for each page will be stored in an XML file. I’ll need a class for the page that handles loading the XML and then kicking off any interaction specific interaction code. So a base template class and a few subclasses for each specific type.

Also need to come up with a schema for the XML and keep it as human readable as possible. Keeping the structure separate from the content of the questions should help a little. But as the complexity of the simulation goes up so will the mark up. I’m not quite sure how the variables and evaluations of the dynamic state will even be defined yet.

All of that will probably take me a week or so to get though. I’ll have screen shots up as I make progress.