Run SDK 0.6.38

Today we’re releasing Run SDK v0.6.38. This release adds a new function to load jigs from a prepared state file so that you can safely ship jigs with your app or library, and a few other minor changes too. Install it from NPM or download it here.


Feature: Load jigs from your local state synchronously

Starting in 0.6.38, you can use the new function Run.util.recreateJigsFromStates(states) to synchronously loads jigs from a state bundle you’ve prepared. This means you can bundle your jigs with your app so that they can be used as soon as your app starts. You can also create libraries that use your on-chain code without needing to await run.load() them first. We’re already using this too in Run for all the built-in Extras (Token, sha256, etc.).

Let’s run though an example:

  1. First, find the jigs you wish to load:

    We’ll choose e20c044e8a09b548860bb71d0ef475721fec042f6b6041bc51d9f0e6cf690a97_o2.

  2. Next, get the state bundle for that jig:

    A state bundle is a JSON data structure containing an object with all of the states needed to completely load a jig. If a class extends from another class, both classes must be in the bundle. There are multiple ways to get a state bundle. You can use the cache, or Run-DB, but for this example we’ll use the Run State API:

    The all=1 query parameter tells the API to return the complete state bundle instead of just a single jig state. You can save this as the file states.json which you would ship with your app

  3. Finally, when your app or library starts call the function with the states:

const jigs = Run.util.recreateJigsFromState(require('./states.json'))

const PsychoParrotContract = jigs.e20c044e8a09b548860bb71d0ef475721fec042f6b6041bc51d9f0e6cf690a97_o2;

That’s it!

Improvement: Better logging for timeouts

If you see a timeout while loading or syncing a jig, the error message now has the jig location in it that failed:

TimeoutError: load timeout (258594f43ea2623caf8d5109d2027c9b1f303916cfb59672130ba43704269e1c)

Timeouts usually happen when there is a problem with the state indexer (Run State API or Run DB). This improved messaging will make any timeouts much easier to debug.

Bugfix: B berries sometimes fail to load in Safari

If you’ve seen a metadata mismatch error while loading B berries on Safari, this is now fixed.

The Run Extras library now loads deterministically from state files as it should have.

API Change: The Extras classes on testnet have moved to Run.extra.test.*

All of the Run Extras classes and functions, like Run.extra.Token, will only work on mainnet now. You can still use them on testnet but you must use the testnet versions and be explicit. This is safer too! The Token class on testnet is now Run.extra.test.Token and same for the others.