Skip to content

With the Provable oracle in this Truffle box, you can create data-rich smart-contracts in seconds!

License

Notifications You must be signed in to change notification settings

provable-things/truffle-starter

Repository files navigation

📦 Provable Truffle Box

 

The Provable Truffle box is here! We have created this starter-box to show you how to leverage Provable within the Truffle framework. It contains the Provable API as well as an example smart-contract. There are tests included too showing you how you could set up a full ethereum smart-contract development suite of your own. Get leveraging the power of Provable in your smart-contract projects today!

 


 

📃 Instructions For Unboxing

1) Using your favourite shell, create a directory you want to install the box into:

❍ mkdir my-awesome-provable-truffle-box

2) Enter the directory:

❍ cd my-awesome-provable-truffle-box

3) Unbox it!

❍ npx truffle unbox provable-things/truffle-starter

Now is a great time to have a look around the your new Provable box. You'll see all the Truffle files & folder structure you're used to. Congratulations - you can now compile, migrate and deploy your contracts to your heart's content!

 


 

🎓 How To Use - Test Running Example

When you unboxed this, it installed the dependencies it needs including another part of the Provable ecosystem that we call the Ethereum-Bridge. It allows you to test Provable functionality on local test-nets! Also, did you know that Truffle can spin up a local ethereum blockchain itself in order to speed up development and run tests? These things combined are super useful when developing your smart-contracts, as a fast test-turnover incentivizes more thorough testing which is always a good thing!

To help even more, we've written a script in the package.json that came inside your Truffle box - go and have a peek at it now. It'll start the bridge with the right settings which will make your work super easy and fast, watch:

1) Point your console to your project's directory then start Truffle in develop mode by running:

❍ npx truffle develop

2) Once Truffle is fired up, in a new console, create the bridge via:

❍ npm run bridge

2) Once the bridge is up, running and listening, go back to the first console and run the tests via:

❍ truffle develop> test

  Contract: ETH Price Tests
    ✓ Should get contract instantiation for listening to events
    ✓ Should have logged a new Provable query on contract creation
    ✓ Callback should have logged a new ETH price (4676ms)
    ✓ Should set ETH price correctly in contract
    ✓ Should revert on second query attempt due to lack of funds (120ms)
    ✓ Should succeed on a second query attempt when sending funds (97ms)
   6 passing (6s)

✅ The more green . . .

✅ check marks . . .

✅ the better!!

Afer you've watched the tests run, go and have a look in the test directory to see the javascript file that contains them. Notice the waitForEvent function in the ./test/utils.js folder too - it means we can wait for events to see what values the Provable calls are returning!

 


 

💻 Get Developing!

Now that you've seen the contents of the Provable box in action, you'll be itching to get on with your own projects. Just remember that if you're using Provable queries in your smart-contracts, you'll need the ethereum-bridge running along side the truffle development console. The bridge is also highly configurable to suit the development environment & version of the ethereum blockchain you're using - you can find out all of it's options here.

There are also tons of other resources to help you out, including:

👊 The Provable docs!

👊 The Truffle docs!

👊 And more of our example contracts!

If you get stuck after looking through the above sources, feel free to ask us questions on our Gitter support channel!

With just this truffle-box you can quickly and easily be leveraging the full power of Provable in your smart-contracts - have fun!

 


 

📣 Get In Touch!

If you want to tell us something, or ask us something, there's loads of ways to get in touch:

We have a Twitter

And a Gitter

Or a Website

Plus a Github

About

With the Provable oracle in this Truffle box, you can create data-rich smart-contracts in seconds!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •