Skip to content

Commit

Permalink
docs(contract): add hint to don't depend on compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Sep 10, 2023
1 parent c5fe1bf commit 52c40f9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/guides/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ Note:
const contract = await aeSdk.initializeContract({ sourceCode, fileSystem })
```

### By path to source code (available only in Node.js)
It can be used with both CompilerCli and CompilerHttp. This way contract imports would be handled automatically, with no need to provide `fileSystem` option.
```js
const sourceCodePath = './example.aes'
const contract = await aeSdk.initializeContract({ sourceCodePath })
```

### By ACI and bytecode
If you pre-compiled the contracts you can also initialize a contract instance by providing ACI and bytecode:

Expand Down Expand Up @@ -103,6 +110,10 @@ const contract = await aeSdk.initializeContract({ aci, address })
- You wouldn't want to provide an `amount` to each transaction or use the same `nonce` which would result in invalid transactions.
- For options like `ttl` or `gasPrice` it does absolutely make sense to set this on contract instance level.

### Keep bytecode and ACI for future use
After the contract is initialized you can persist values of `contract._aci` and `contract.$options.bytecode`.
They can be provided for subsequent contract initializations to don't depend on a compiler.
## 5. Deploy the contract
If you have a Sophia contract source code that looks like this:
Expand Down

0 comments on commit 52c40f9

Please sign in to comment.