Skip to content

Instantly share code, notes, and snippets.

@conr2d
conr2d / code_hash.hpp
Last active February 4, 2023 17:38
EOSIO GET_CODE_HASH example
#pragma once
#include <eosio/fixed_bytes.hpp>
#include <eosio/name.hpp>
#include <eosio/varint.hpp>
#include <array>
namespace eosio {
namespace internal_use_do_not_use {
extern "C" {
@conr2d
conr2d / CMakeLists.txt
Created September 7, 2021 20:54
supported options of eosio.cdt in blanc v0.10
add_executable(eosio.token src/eosio.token.cpp)
#target_compile_options(eosio.token PUBLIC --contract=eosio.token)
target_compile_definitions(eosio.token PUBLIC -DEOSIO_CONTRACT=eosio.token)
#target_compile_options(eosio.token PUBLIC --abi-version=1.2)
target_compile_definitions(eosio.token PUBLIC -DEOSIO_ABI_VERSION=1.2)
#target_compile_options(eosio.token PUBLIC --no-abigen)
target_compile_definitions(eosio.token PUBLIC -DEOSIO_NO_ABIGEN)
@conr2d
conr2d / CMakeLists.txt
Last active September 7, 2021 20:48
clion with blanc - way1
cmake_minimum_required(VERSION 3.16)
project(eosio.token)
find_package(blanc)
include(EosioWasmToolchain)
add_contract(eosio.token eosio.token src/eosio.token.cpp)
target_include_directories(eosio.token PUBLIC include)
@conr2d
conr2d / CMakeLists.txt
Last active April 28, 2023 12:16
clion with blanc - way2
cmake_minimum_required(VERSION 3.16)
set(CMAKE_DEPENDS_USE_COMPILER FALSE)
project(eosio.token)
set(CMAKE_CXX_COMPILER_TARGET wasm32) # This option is important
set(CMAKE_EXECUTABLE_SUFFIX_CXX .wasm) # Set this or set the target name with .wasm suffix
add_executable(eosio.token src/eosio.token.cpp)
target_include_directories(eosio.token PUBLIC include)
@conr2d
conr2d / eosjs-name.ts
Last active April 2, 2021 02:25
Simple conversion between name and uint64 with eosjs
import { Serialize } from 'eosjs';
const types = Serialize.createInitialTypes();
const nameToUint64 = (name: string): string => {
let ser = new Serialize.SerialBuffer();
ser.pushName(name);
return types.get('uint64').deserialize(ser);
};
@conr2d
conr2d / merge.sh
Created October 21, 2020 02:40
A shell script for merging git submodules to the main repository
#!/bin/bash
#
# This script merges all submodules into the main repository.
# You need to put this file in the parent directory or home directory,
# but run in the repository directory.
# Otherwise, this file will be included in your repository. (or, add merge.sh to .gitignore)
#
# $ ../merge.sh
if [[ ! -z $(git submodule status --recursive | grep "^[+\-]") ]]; then
@conr2d
conr2d / ERC20.sol
Last active August 11, 2020 05:28
ERC20 interfaces
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.7.0;
contract ERC20 {
string public name;
string public symbol;
uint8 public decimals;
uint public totalSupply;
mapping(address => uint) balances;
function timestampToDate(UNIX_timestamp) {
let a = new Date(UNIX_timestamp * 1000);
let months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
let year = a.getFullYear();
let month = months[a.getMonth()];
let date = a.getDate();
let hour = a.getHours();
let min = a.getMinutes();
let sec = a.getSeconds();
let time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
pragma solidity >=0.4.22 <0.7.0;
import "remix_tests.sol";
import "remix_accounts.sol";
import "../ERC20.sol";
contract ERC20Test is ERC20 {
string testName = "MyToken";
string testSymbol = "MTN";
uint8 testDecimals = 2;
@conr2d
conr2d / test.cpp
Last active December 9, 2022 17:20
Pack parameters example
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
using namespace eosio;
using namespace std;
class test: public contract {
public:
using contract::contract;