Skip to content

Instantly share code, notes, and snippets.

@kalouo
kalouo / FA2_fungible.py
Created August 14, 2022 18:55
Chinstrap FA2 origination with allocated tokens.
# Exampel of storage whereby fungible tokens are allocated at origination.
def deploy(chinstrapState, network, accounts):
contract = getContract("test_currency")
initial_storage = contract.storage.encode(
{
"administrator": accounts[0].key.public_key_hash(),
"last_token_id": 1,
"ledger": {
# The value is exponentiated by the token decimal.
@kalouo
kalouo / compile.sh
Last active September 21, 2021 18:59
Tezos IDE
#!/usr/bin/env bash
set -e -o pipefail
echo "----------------------------------------"
echo "Compiling contracts ... "
echo "----------------------------------------"
# Expected location of SmartPy CLI.
SMART_PY_CLI=~/smartpy-cli/SmartPy.sh
@kalouo
kalouo / 001_deploy_test.ts
Last active April 18, 2023 13:50
Smart contracts with Hardhat
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
deployments: { deploy },
getNamedAccounts,
} = hre;
const { deployer } = await getNamedAccounts();
@kalouo
kalouo / challenge.md
Last active April 2, 2021 02:48
Zipmex Backend Challenge

Zipmex Backend Challenge

Welcome to the Zipmex backend challenge! Thanks for attempting it, we wish you good luck!

We prefer well-thought out, quality code over quick-and-dirty solutions. So - please take your time, if you need it.

Instructions

  • Create an server application in your language/framework of choice.
  • Write an algorithm that will take a JSON object structured like Appendix 1 Input and transform it into the structure shown under Appendix 2 Output. In other words, the algorithm will place "children" objects under the correct "parent" objects.
/*
As a user I can enter a phrase "hello" and see it translated to Pig Latin "ellohay"
As a user I can enter a phrase "hello world" and see it translated to Pig Latin "ellohay orldway"
As a user I can enter a phrase "Hello World" and see it translated to Pig Latin "Ellohay Orldway"
As a user I can enter a phrase "Hello, world!" and see it translated to Pig Latin "Ellohay, orldway!"
As a user I can enter a phrase "eat apples" and see it translated to Pig Latin "eatay applesay"
As a user I can enter a phrase "quick brown fox" and see it translated to Pig Latin "ickquay ownbray oxfay"
*/
@kalouo
kalouo / game.ex
Last active December 15, 2020 10:16
GenServer, DynamicSupervisor and Registry
defmodule GamePlatform.Game do
use GenServer
require Logger
@registry :game_registry
@initial_state %{players: []}
## GenServer API
def start_link(name) do
@kalouo
kalouo / matchRequestBy.ts
Last active December 3, 2020 08:09
Tests With Mocks and Recordings
{
method: true,
headers: false,
body: true,
order: false,
url: {
protocol: false,
username: false,
password: false,
hostname: true,
@kalouo
kalouo / Trade.sol
Created September 5, 2019 09:38
Solidity Transaction Contract
pragma solidity ^0.5.0;
contract Trade {
enum tradingState { created, funded, transit, completed}
struct TradeSummary {
address payable seller;
address payable buyer;
address carrier;