-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1474 from smartcontractkit/chores/update-truffle-box
Add scripts to our Truffle Box
- Loading branch information
Showing
8 changed files
with
132 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
let MyContract = artifacts.require('MyContract') | ||
let LinkToken = artifacts.require('LinkToken') | ||
|
||
/* | ||
This script is meant to assist with funding the requesting | ||
contract with LINK. It will send 1 LINK to the requesting | ||
contract for ease-of-use. Any extra LINK present on the contract | ||
can be retrieved by calling the withdrawLink() function. | ||
*/ | ||
|
||
const payment = process.env.TRUFFLE_CL_BOX_PAYMENT || '1000000000000000000' | ||
|
||
module.exports = async (callback) => { | ||
let mc = await MyContract.deployed() | ||
let tokenAddress = await mc.getChainlinkToken() | ||
let token = await LinkToken.at(tokenAddress) | ||
console.log('Funding contract:', mc.address) | ||
let tx = await token.transfer(mc.address, payment) | ||
callback(tx.tx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let MyContract = artifacts.require('MyContract') | ||
|
||
/* | ||
This script makes it easy to read the data variable | ||
of the requesting contract. | ||
*/ | ||
|
||
module.exports = async (callback) => { | ||
let mc = await MyContract.deployed() | ||
let data = await mc.data.call() | ||
callback(data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
let MyContract = artifacts.require('MyContract') | ||
|
||
/* | ||
This script allows for a Chainlink request to be created from | ||
the requesting contract. Defaults to the Chainlink oracle address | ||
on this page: https://docs.chain.link/docs/testnet-oracles | ||
*/ | ||
|
||
const oracleAddress = process.env.TRUFFLE_CL_BOX_ORACLE_ADDRESS || '0xc99B3D447826532722E41bc36e644ba3479E4365' | ||
const jobId = process.env.TRUFFLE_CL_BOX_JOB_ID || '9f0406209cf64acda32636018b33de11' | ||
const payment = process.env.TRUFFLE_CL_BOX_PAYMENT || '1000000000000000000' | ||
const url = process.env.TRUFFLE_CL_BOX_URL || 'https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD' | ||
const path = process.env.TRUFFLE_CL_BOX_JSON_PATH || 'USD' | ||
const times = process.env.TRUFFLE_CL_BOX_TIMES || '100' | ||
|
||
module.exports = async (callback) => { | ||
let mc = await MyContract.deployed() | ||
console.log('Creating request on contract:', mc.address) | ||
let tx = await mc.createRequestTo( | ||
oracleAddress, | ||
web3.utils.toHex(jobId), | ||
payment, | ||
url, | ||
path, | ||
times | ||
) | ||
callback(tx.tx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters