isPrimary:false,// Creates a social token explicitly associated with the collective by pda, instead of the wallet alone.
name:"Learning Strata Token",
ignoreIfExists:true,// If a Social Token already exists for this wallet, ignore.
Fetch the created token:
var tokenBondingAcct =await tokenBondingSdk.getTokenBonding(tokenBonding);
var ownerTokenRefAcct =await tokenCollectiveSdk.getTokenRef(ownerTokenRef);
Notice that we created a non-primary social token here. Most wallets will have one social token. For ease of lookup, social tokens refs are a PDA of the owner alone. In the case where one wallet belongs to several collectives, they should choose one isPrimary token that is used for lookups on storefronts.
The name service allows you to create unique strings on chain owned by a particular wallet. A name consists of
Class - The name class must sign the issuance of a name.
Owner - The owner of this name
Parent - The parent name of this name. In practice, this can be used like a class hierarchy.
Parent Owner - The parent name has an owner. If a name has a parent, the parent's owner must also sign the issuance of this name.
This might seem a little abstract, so let's go with an example. Let's say we want to associate unclaimed tokens with twitter users. When a twitter user verifies they own their handle, we let them claim the token.
We want to gate who can claim ownership of a twitter handle, so we will assign a verifier keypair as the name class that must approve issuance.
While this example is focused on twitter, this could just as easily work for usernames on your own website. This is a generic framework for onboarding social tokens that users can later claim using their wallet.
This is what we will build:
First, we create a name parent that is our twitter tld
We often refer to a name parent as the Top Level Domain (TLD). In the case of twitter, we have a twitter top level domain that all twitter handles are under.
// Explicitly don't have the verifier sign this, it should fail
var txid =await provider.send(nameTx);
Let's create an unclaimed token for the twitter handle "test-...":
The name service name for the user does not have to exist for us to create a token for them. We can lazily create the name when the user wants to claim their token. This also allows us to pass the fees for the name creation on to the user.