Skip to content

Instantly share code, notes, and snippets.

View andrejrakic's full-sized avatar
:octocat:
Building Chainlink

Andrej andrejrakic

:octocat:
Building Chainlink
View GitHub Profile
@andrejrakic
andrejrakic / go-stdlib-interface-selected.md
Created March 9, 2024 11:46 — forked from asukakenji/go-stdlib-interface-selected.md
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

@andrejrakic
andrejrakic / LogEmitter.sol
Created November 21, 2023 15:17
Data Streams workshop
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.19;
contract LogEmitter {
event Log(address indexed msgSender);
function emitLog() public {
emit Log(msg.sender);
}
@andrejrakic
andrejrakic / readme.md
Last active October 13, 2023 18:40
Go vs Rust vs Node.js

Go vs Rust vs Node.js

Command Go Rust Node.js
Installation go install rustup nvm/volta/n/fnm
Package Manager go cargo npm/yarn/pnpm
Configuration go.mod Cargo.toml package.json
Testing go test cargo test jest/vitest/node:test
Building go build cargo build Webpack/turbo
@andrejrakic
andrejrakic / Caller.sol
Created May 18, 2022 23:10
Middleman contract example for DevConnect Game
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// x ----->
// _______________
// y |____|____|_____
// |____|____|_____
// |____|____|_____
// |____|____|_____
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
contract StorageBug is Ownable {
function write(uint256 number) external onlyOwner {
uint256[] storage arr;
arr.push(number);
@andrejrakic
andrejrakic / Swapper.sol
Created August 26, 2021 11:28
Simple smart contract to swap two variables in Solidity
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
// Simple contract to swap two variables in Solidity
contract Swapper {
uint8 public x = 1;
uint8 public y = 2;
function swap() public {

👍 Examples of correct code ordering rule

All units are in order

pragma solidity ^0.7.0;

import "./some/library.sol";
import "./some/other-library.sol";
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.10;
/*
EtherStore is a contract where you can deposit any amount and withdraw at most
1 Ether per week. This contract is vulnerable to re-entrancy attack.
Let's see why.
1. Deploy EtherStore
2. Deposit 1 Ether each from Account 1 (Alice) and Account 2 (Bob) into EtherStore
pragma solidity 0.4.24;
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.4/ChainlinkClient.sol";
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.4/vendor/Ownable.sol";
contract ATestnetConsumer is ChainlinkClient, Ownable {
uint256 constant private ORACLE_PAYMENT = 1 * LINK;
uint256 public currentPrice;
int256 public changeDay;
@andrejrakic
andrejrakic / ERC721.sol
Created August 7, 2020 11:37
ERC721.sol
pragma solidity ^0.5.1;
/**
* @dev ERC-721 non-fungible token standard.
* See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md.
*/
interface ERC721
{
/**