Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mingderwang/e9f33329e940ec19de61f400e0b7917a to your computer and use it in GitHub Desktop.
Save mingderwang/e9f33329e940ec19de61f400e0b7917a to your computer and use it in GitHub Desktop.
setfulfillmentpermission_script.js
let ethers = require('ethers')
let provider = new ethers.providers.JsonRpcProvider(process.env.KOVAN_RPC_URL)
let oracleAddress = '0x4E9b9E70d72c919E0c7C1F47a7d6CD84B1A0C4E0'
let oracleAbi = [
{
"constant": false,
"inputs": [
{
"name": "_sender",
"type": "address"
},
{
"name": "_payment",
"type": "uint256"
},
{
"name": "_specId",
"type": "bytes32"
},
{
"name": "_callbackAddress",
"type": "address"
},
{
"name": "_callbackFunctionId",
"type": "bytes4"
},
{
"name": "_nonce",
"type": "uint256"
},
{
"name": "_dataVersion",
"type": "uint256"
},
{
"name": "_data",
"type": "bytes"
}
],
"name": "oracleRequest",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_requestId",
"type": "bytes32"
},
{
"name": "_payment",
"type": "uint256"
},
{
"name": "_callbackAddress",
"type": "address"
},
{
"name": "_callbackFunctionId",
"type": "bytes4"
},
{
"name": "_expiration",
"type": "uint256"
},
{
"name": "_data",
"type": "bytes32"
}
],
"name": "fulfillOracleRequest",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "EXPIRY_TIME",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "withdrawable",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_requestId",
"type": "bytes32"
},
{
"name": "_payment",
"type": "uint256"
},
{
"name": "_callbackFunc",
"type": "bytes4"
},
{
"name": "_expiration",
"type": "uint256"
}
],
"name": "cancelOracleRequest",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_node",
"type": "address"
},
{
"name": "_allowed",
"type": "bool"
}
],
"name": "setFulfillmentPermission",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_sender",
"type": "address"
},
{
"name": "_amount",
"type": "uint256"
},
{
"name": "_data",
"type": "bytes"
}
],
"name": "onTokenTransfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_node",
"type": "address"
}
],
"name": "getAuthorizationStatus",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_recipient",
"type": "address"
},
{
"name": "_amount",
"type": "uint256"
}
],
"name": "withdraw",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_link",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "specId",
"type": "bytes32"
},
{
"indexed": false,
"name": "requester",
"type": "address"
},
{
"indexed": false,
"name": "requestId",
"type": "bytes32"
},
{
"indexed": false,
"name": "payment",
"type": "uint256"
},
{
"indexed": false,
"name": "callbackAddr",
"type": "address"
},
{
"indexed": false,
"name": "callbackFunctionId",
"type": "bytes4"
},
{
"indexed": false,
"name": "cancelExpiration",
"type": "uint256"
},
{
"indexed": false,
"name": "dataVersion",
"type": "uint256"
},
{
"indexed": false,
"name": "data",
"type": "bytes"
}
],
"name": "OracleRequest",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "requestId",
"type": "bytes32"
}
],
"name": "CancelOracleRequest",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
}
],
"name": "OwnershipRenounced",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
}
]
let wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider)
let oracle = new ethers.Contract(oracleAddress, oracleAbi, wallet)
let gasPrice = 30000000000
const main = async () => {
let overrides = {
gasPrice: 30000000000
}
let address = "0xeAD8385E9e4a7643DeB97D548A05733D2C5a6861"
let contractWithSigner = oracle.connect(wallet)
// set the address here to the node wallet address (regular address not emergency)
let tx = await contractWithSigner.setFulfillmentPermission(address, true, overrides)
await tx.wait()
let authStatus = await contractWithSigner.getAuthorizationStatus(address)
console.log(authStatus)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment