Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions user-guide/docs/invoking-your-first-function-with-js-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ To follow this tutorial, you should already have done the following:
## 1. Run the Hello Conclave Cloud project

* Get the [Hello Conclave Cloud Tutorial](https://github.com/R3Conclave/conclave-cloud-samples/) repository:

```
git clone https://github.com/R3Conclave/conclave-cloud-samples.git
```

* Change to the `hello-conclave-cloud-tutorial` directory.

* Install and run the project:

`npm install`
`npm start`

Expand All @@ -32,23 +33,26 @@ To follow this tutorial, you should already have done the following:
## 2. Install and configure the Conclave Cloud SDK

* Install the conclave-cloud-sdk npm package:

`npm install /path to file/conclave-cloud-sdk-1.0.0-beta2.tgz --save`

* Create a project.

* In the project's root directory, create a new file and call it `ConclaveCloud.js`.

* Create an API key using the Conclave Cloud CLI command line tool:

`ccl apikeys create`

* Add the following configurations to `ConclaveCloud.js`
```
import { Conclave } from 'conclave-cloud-sdk'
const conclaveConfig = new Conclave.create({
apiKey: 'apiKey' // replace with the apiKey you've created.
});
export default conclaveConfig;
```

```
import { Conclave } from 'conclave-cloud-sdk'
const conclaveConfig = new Conclave.create({
apiKey: 'apiKey' // replace with the apiKey you've created.
});
export default conclaveConfig;
```

_Note_

Expand All @@ -58,28 +62,31 @@ _Note_
## 3. Invoke Call via SDK

* Import conclaveConfig into the app.tsx file

```
import conclaveConfig from "./ConclaveCloud";
```

* Add the following to the `sendMessage` function:

```
response = await conclaveConfig.functions.call(
"function name",
"function hash",
[args]
);
response = await conclaveConfig.functions.call(
"function name",
"function hash",
[args]
);
```

> The [args] value is the input value from the project.

* It should look like this:

```
response = await conclaveConfig.functions.call(
"sayHello",
"60C5AEFCE46A44163467EC82C204AB5207B780A45527A65A6580886AECAC49D4",
[input]
);
response = await conclaveConfig.functions.call(
"sayHello",
"60C5AEFCE46A44163467EC82C204AB5207B780A45527A65A6580886AECAC49D4",
[input]
);
```

* You can now invoke the function from the UI.
Expand All @@ -93,13 +100,15 @@ including polyfills:
### Downgrading react-scripts:

* Run the following commands:

`npm uninstall react-scripts`
`npm install [email protected]`

### Adding a Webpack config file with fallback:

* In the root project directory, create the file webpack.config.js.
* In the root project directory, create the file `webpack.config.js`.
* Add the following to webpack.config.js:

```
module.exports = {
resolve: {
Expand All @@ -112,6 +121,7 @@ including polyfills:
```

* Run the following command.

`npm install crypto-browserify stream-browserify --save`

### Adding fallback to react-script's webpack configuration file:
Expand All @@ -120,6 +130,7 @@ including polyfills:
module.exports section.

* In the module.exports section, find the resolve section, and add the following:

```
fallback: {
crypto: require.resolve('crypto-browserify'),
Expand All @@ -128,6 +139,7 @@ including polyfills:
```

* The section should look like this:

```
module.exports = function (webpackEnv) {
...
Expand All @@ -152,6 +164,7 @@ including polyfills:
* In the root project directory, create a file `config-overrides.js`

* Add the following code to the `config-overrides.js` file:

```
module.exports = function override(config) {
const fallback = config.resolve.fallback || {};
Expand All @@ -168,10 +181,12 @@ including polyfills:
`npm install crypto-browserify stream-browserify --save`

* In package.json, substitute the start scripts with the following lines:

```
"scripts": {
"start": "react-app-rewired start",
```

* Run the following command:

`npm start`