Skip to content

Instantly share code, notes, and snippets.

View ijonas's full-sized avatar

Ijonas Kisselbach ijonas

View GitHub Profile
@ijonas
ijonas / README.md
Last active October 17, 2022 04:32
Antoine Oracle

Antoine's Oracle

This is a sample smart contract that connects to the Translucent Oracle on Goerli and retrieves a dynamic list of strings from a JSON API.

Oracle Job Details

  • Oracle Address - 0x188b71C9d27cDeE01B9b0dfF5C1aff62E8D6F434
  • Job ID - a72b502cccf444e49e4d4768017b6572
  • LINK token address on Goerli - 0x326C977E6efc84E512bB9C30f76E30c160eD06FB

Calling the API

did:3:kjzl6cwe1jw14a87dw54bfecnxqzthlqp91djo21z9exi8oz9wyqkl7x09ytiyu
type = "directrequest"
schemaVersion = 1
name = "Get > Uint256 0.05LINK"
minContractPaymentLinkJuels = 50000000000000000
maxTaskDuration = "0s"
contractAddress = "CONTRACT ADDRESS"
minIncomingConfirmations = 0
observationSource = """
decode_log [type="ethabidecodelog"
abi="OracleRequest(bytes32 indexed specId, address requester, bytes32 requestId, uint256 payment, address callbackAddr, bytes4 callbackFunctionId, uint256 cancelExpiration, uint256 dataVersion, bytes data)"
@ijonas
ijonas / CallingContract.sol
Last active April 5, 2022 12:20
Fetching a string-value via an Oracle
contract MyContract {
string public lastMarket;
function requestEthereumLastMarket(address _oracle, string memory _jobId)
public
onlyOwner
{
Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(_jobId), address(this), this.fulfillEthereumLastMarket.selector);
req.add("get", "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=ETH&tsyms=USD");
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.8.7;
pragma abicoder v2;
import './TransferHelper.sol';
import './ISwapRouter.sol';
contract SwapExamples {
// For the scope of these swap examples,
// we will detail the design considerations when using
pragma solidity 0.7.1;
import "https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router02.sol";
contract UniswapExample {
address internal constant UNISWAP_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ;
IUniswapV2Router02 public uniswapRouter;
address private multiDaiKovan = 0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa;
# DEV
account_id = 3
case_type_id = 22
bucket_id = 102
admin_user_id = 8
current_state_id = 72
# QA
account_id = 1
case_type_id = 18
@ijonas
ijonas / gist:0386c6e01c1479c9321e162be137d95c
Created September 19, 2016 21:39
How to handle errors in #golang
Below are a bunch of resources that help you grok error handling in Go.
* Listen to Go Time Podcast #16, specifically the parts on error handling https://changelog.com/gotime-16/
* Read http://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully
* Read http://dave.cheney.net/2016/06/12/stack-traces-and-the-errors-package
* Use the errors pkg for some syntactic sugar... https://godoc.org/github.com/pkg/errors
Use Dave Cheney's "rules"... either handle the error locally and then never again (e.g. log to stderr) OR
pass the error up the call stack. Consider annotating the error... errors.Wrapf(err, "Unable to access %s upload folder", account)
before passing it back up the stack.
TASK [setup] *******************************************************************
ok: [localhost]
TASK [genesis-digitalocean : Get the default SSH key] **************************
changed: [localhost]
TASK [genesis-digitalocean : Add the SSH key to DigitalOcean if it doesn't already exist] ***
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: name 'DoError' is not defined
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/var/folders/b_/pqyqvn4s0xldl2cm4mfnqkb00000gn/T/ansible_8biPQo/ansible_module_digital_ocean.py\", line 187, in <module>\n class TimeoutError(DoError):\nNameError: name 'DoError' is not defined\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
@ijonas
ijonas / gist:41e3a155e94c64fc4630
Created April 1, 2015 09:05
ReactNative NavigatorIOS component doesn't pass 'navigator' object into props
var CBSupport = React.createClass({
_handleNextButtonPress: function() {
debugger
AlertIOS.alert("Be A Lert");
// this.props does not contain a 'navigator' property
this.props.navigator.push({
component: Login,
title: 'Login'
});