0xBlue2 / js-setup

basic js for chall

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

js-setup

basic js for chall

KNOWN ISSUES:

  • bytecode.bin has extra newline, making it 2 lines long
    • ethers will interpret that \n as a byte in bytecode, reports "Error: invalid bytecode"
    • solution: remove newline after cloning repo

SETUP:

  • create package.json

    • without it, npm tries to install packages to your home directory(~/node_modules) I think
    • add pair of brackes('{}') to package.json
    • linux: echo '{}' > package.json
  • install npm and node

    • tons of ways to do it, I just installed node from the website(https://nodejs.org/en/download/ - npm comes with it) and symlinked the node and npm binaries to ~/.local/bin
    • node runs .js files, npm lets you install ethers
  • install ethers(npm library)

    • npm install ethers (makes node_modules dir to use ethers in that dir only)
    • or sudo npm install ethers -g (idk how this works, but it makes ethers lib accessible from anywhere)
    • note: ^ sudo ... -g borked my system later on, but that might have been bc I'd never used npm/node before
  • "install" ganache(mock blockchain gui)

    • ganache sets up a test blockchain locally and gives you a nice gui to see it
    • dont really need to "install" for linux, its just a standalone appimage
    • get from: https://trufflesuite.com/ganache/
  • optional: install vscode extension(if on kali linux, it's not available in code-oss - you have to use the propietary version from msft i think its available now, dont quote me tho)

RUN:

Install ethers lib, run ganache, copy/paste pubkey & privkey of address you want to use into deploy.js, then:

node deploy.js

FILES:

  • abi.json
  • bytecode.bin
    • came from same link above^ : "Contract Creation Code"
  • deploy.js
    • deploys Totally-Secure-Dapp to ganache(ganache must already be running)
  • interact-local.js
    • script to interact with local contract from deploy.js
  • Initializable.sol and TotallySecureDapp.sol
    • arent needed to run js scripts or anything, but nice to reference
  • interact-remote.js
    • script to interact with actual dapp from chall

About

basic js for chall


Languages

Language:Solidity 63.7%Language:JavaScript 36.3%