Optional - Set format on save and any global prettier options
npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
// EDIT: It's now much easier to get metadata from metaplex using the js package. | |
// Check the new gist here: https://gist.github.com/dvcrn/a1b0ff0a0b4b3ab02aff44bc84ac4522 | |
// I didn't want to edit this gist because a lot of people found it helpful to see how to manually decode a account | |
import * as web3 from "@solana/web3.js"; | |
import * as metadata from "./metadata"; // see metadata.ts | |
const tokenAddress = new web3.PublicKey( | |
"CxkKDaBvtHqg8aHBVY8E4YYBsCfJkJVsTAEdTo5k4SEw" | |
); |
Some of the bit twiddling in my Solidity implementation of an on-chain engine, fiveoutofnine.sol, can be quite esoteric, so I've recreated some of the logic below. Note that the code below is only logically equivalent (gives same results, but do different things). Functions have similar names, so it should be pretty easy to match up to the functions from Chess.sol
and Engine.sol
. The main abstraction in these files are using an array for the board (as opposed to 64 bitpacked uint4
s) and struct for moves (as opposed to 2 bitpacked uint6
s). To further simplify it, it's in a language anyone can read easily: Python.
class Move:
def __init__(self, from, to):
self.from = from
self.to = to