When you deploy a Typescript 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.
This approach introduces a dependency on Github’s availability. We aim to directly support private Web3 Function deployments in the future.
This Typescript 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
Check out an example of a GitHub gist with onRun.js
here.
onRun.js
should return a promise.
Dependencies that are used in onRun.js
should be imported into the Web3 Function index.ts
file, not in onRun.js
.
Web3 Function context which includes, secrets, userArgs, multiChainProvider can be accessed normally in onRun.js
.
Results returned in onRun.js
will be bubbled up and returned in the private Web3 Function.
GIST_ID
(Github gist id to fetch onRun.js
from)Make sure to store your GitHub gist id as a secret.
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:
When you deploy a Typescript 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.
This approach introduces a dependency on Github’s availability. We aim to directly support private Web3 Function deployments in the future.
This Typescript 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
Check out an example of a GitHub gist with onRun.js
here.
onRun.js
should return a promise.
Dependencies that are used in onRun.js
should be imported into the Web3 Function index.ts
file, not in onRun.js
.
Web3 Function context which includes, secrets, userArgs, multiChainProvider can be accessed normally in onRun.js
.
Results returned in onRun.js
will be bubbled up and returned in the private Web3 Function.
GIST_ID
(Github gist id to fetch onRun.js
from)Make sure to store your GitHub gist id as a secret.
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: