Private Web3 Functions
Deployed Web3 Functions are public
When you deploy a Web3 Function the code is stored and pinned on IPFS making it accessible to everyone. If you would prefer to conceal your code, one approach is to store your code in a private Github Gist. Subsequently, this code can be retrieved and executed through a Web3 Function.
Note: this approach introduces a dependency on Github's availability. We aim to directly support private Web3 Function deployments in the future.
Private Web3 Function example
This Web3 Function fetches onRun.js
(Github gist containing concealed code) with its gist id and executes it during runtime. Check out the example on GitHub here.
The code in onRun.js
must be in JavaScript
Writing onRun.js
onRun.js
Check out an example of a GitHub gist with onRun.js
here.
1. onRun.js
file structure
onRun.js
file structureonRun.js
should return a promise.
2. Using dependencies
Dependencies that are used in onRun.js
should be imported into the Web3 Function index.ts
file, not in onRun.js
.
3. Accessing Web3 Function Context
Web3 Function context which includes, secrets
, userArgs
, multiChainProvider
can be accessed normally in onRun.js
.
4. Return Web3 Function result
Results returned in onRun.js
will be bubbled up and returned in the private Web3 Function.
Creating private Web3 Function task
Secrets (strict)
GIST_ID
(Github gist id to fetchonRun.js
from)
Make sure to store your GitHub gist id as a secret.
Arguments (not strict)
Since GitHub gists are editable, you can have a userArgs to be a JSON string so that arguments can be editable without re-deploying a web3 function with a different schema.
Example args
when creating your task:
Last updated