4

Yesterday I learned that the JSON provided from the Alphanet wallet must first be activated using activate account e.g. ./tezos-client activate account myRandomAlias with tzWhAtEvEr.json (thanks Fredcy!) which also led me to find this section in the developer documentation https://tezos.gitlab.io/master/introduction/howtouse.html#get-free-tez.

Is there a way to perform this action without tezos-client, but rather by using a library such as eztz or sotez with a remote provider? I see that sotez does have a "Activate" method, but I have tried several combinations of values extracted from the faucet JSON to no avail. https://github.com/AndrewKishino/sotez/wiki/Documentation#activate

When ZuluRepublic initially engaged Tezos about implementing Tezos into our suite of products, we were told that this could likely be achieved without hosting our own node, but now I am wondering if that isn't true?

Edit: To elaborate, my intention is to handle key generation, storage, transaction building, and signing local (offline methods) and using a remote provider only to fetch public data like blocks, transactions, balances, and to broadcast signed transactions.

I am accustomed to faucets that ask for an address to send tokens to, where I would enter the address to a wallet I control, and then I can begin experimenting with sending and receiving tezzies in my codebase. But with this faucet, it seems like I would need to have my own node so I can use tezos-client to activate it.

5

Yes this is possible with sotez. There initially was a bug with the activate function which was just fixed in 0.2.11. You can do something like the following to activate an account as well as generate the keys:

import { rpc, crypto } from 'sotez';

// tz1eQV2GqDTY7dTucnjzNgvB5nP4H5c7Xr5m.json
const accountJSON = {
  "mnemonic": [
    "raw",
    "peace",
    "visual",
    "boil",
    "prefer",
    "rebel",
    "anchor",
    "right",
    "elegant",
    "side",
    "gossip",
    "enroll",
    "force",
    "salmon",
    "between"
  ],
  "secret": "0c5fa9a3d707acc816d23940efdef01aa071bdc6",
  "amount": "12358548903",
  "pkh": "tz1eQV2GqDTY7dTucnjzNgvB5nP4H5c7Xr5m",
  "password": "wc0W7jn3Vf",
  "email": "gfjilgzu.trfhzzzk@tezos.example.org"
};

const activateAccount = async (accountJSON) => {
  let keys;
  try {
    const activatedOperation = await rpc.activate(accountJSON.pkh, accountJSON.secret);
    await rpc.awaitOperation(activatedOperation.hash);
    keys = await crypto.generateKeys(accountJSON.mnemonic.join(' '), `${accountJSON.email}${accountJSON.password}`);
    console.log(keys);
  } catch (e) {
    console.log(e);
  }
};

activateAccount(accountJSON);

Some things you can see from the example is that the mnemonic is entered as a string and the passphrase is the concatenated email and password values from the JSON file.

4

You can do this using the eztz library. Here are the relevant commands you want to look at:

//Point to alphanet node
eztz.node.setProvider("https://alphanet.tezrpc.me");

//From https://faucet.tzalpha.net/
var faucet = {
  "mnemonic": [
    "viable",
    "decline",
    "spend",
    "excess",
    "hour",
    "panel",
    "decade",
    "sniff",
    "blame",
    "crane",
    "enact",
    "clever",
    "rival",
    "bundle",
    "silk"
  ],
  "secret": "b318178ddad24f1f9f789aecdbe62a4f4723f47f",
  "amount": "19080702922",
  "pkh": "tz1XfgzFAdNijPdANxxJ69wYUdHfYrWr4bqS",
  "password": "Omxz6rDlHz",
  "email": "xktvhnlk.vnzorwib@tezos.example.org"
};

//Generate keys
var keys = eztz.crypto.generateKeys(faucet.mnemonic.join(" "), faucet.email + faucet.password);
if (keys.pkh != faucet.pkh) throw "Invalid";

//Activate
eztz.rpc.activate(faucet.pkh, faucet.secret).then(function(d){
  console.log(d);
});

This queries the remote tezrpc Alphanet node, constructs keys and forges operations locally and injects the activation operation into the node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.