mousebelt / BrowserQuest

A HTML5/JavaScript multiplayer game experiment
http://browserquest.mozilla.org/
Other
2 stars 0 forks source link

Call Create Game from the Stardust SDK #6

Closed gedanziger closed 5 years ago

gedanziger commented 5 years ago

Call Create Game from the stardust SDK, and keep the result:

// CREATE_GAME FUNCTIONS
const hashGame = (gameData) => {
    const{name, symbol, desc, image, owner, nonce} = gameData;
    const gameParamTypes = ['string', 'string', 'string', 'string', 'address', 'uint256'];
    const hashes = hashParams([name, symbol, desc, image, owner, nonce], gameParamTypes);
    return(hashParam(hashes, 'bytes32[]'));
};

const hashAndSignGame = (gameData, privKey) => {
    const sig = accounts.sign(hashGame(gameData), privKey);
    return({'signedMessage': sig.signature + sig.message.slice(2)});
};

const createGamePostJSON = (gameData, privKey) => ({...gameData, ...hashAndSignGame(gameData, privKey)});

Using a keypair stored as an env variable (do NOT store on github, just query env to get it), use these values:

Create a game on the Stardust platform for BrowserQuest using these configs:

Afterwards, keep the info for the game to an application config and update the README for how to set it.

0xweb3builder commented 5 years ago

API base url is noted in #5 comment. @sunrisepopov

gedanziger commented 5 years ago

Verified fixed and closed