diff --git a/src/smart-contracts/concepts/model.md b/src/smart-contracts/concepts/model.md index d29f81e..fb5cf04 100644 --- a/src/smart-contracts/concepts/model.md +++ b/src/smart-contracts/concepts/model.md @@ -52,12 +52,63 @@ Metering is set to false so that the executor does not use any stamps when execu ### Step 1: Submit Transaction -
- +```txt + +----------------+ + +------------------------| Error returned |<-----+ + | | to Executor | | + | +----------------+ | + | Module Loader | + | +----------------+ | + | | - - - | | + | Does this | - - | | + |-------------\ v mart contract | | - - - | | | + | transaction -\ +----------+ exist? | | state |-------No--+ + | submitted - | Executor |----------------->| - - - - | + | to Executor -/ +----------+ | | | + |-------------/ ^ | Yes | + | | | | + | | v | + | | +--------+ | + | | |contract| | + | | +--------+ | + | | | | + +----------------------+ +-------|--------+ + | Smart contract | | + | returned to Executor |-----------+ + +----------------------+ +``` Executor retrieves the module for the smart contract if it exists. ### Step 2: Execution -
+```txt + +------------------------+ + +----------------------------------| Error returned to |<--------+ + | | Executor |<-----+ | + | +------------------------+ | | + | Python VM | | + | +--------------------------+ | | + | | +--------------------+ | | | + | | | Does the function |----No-+ | + | | | exist? | | | + | | +--------------------+ | | + | | | | | + | Execute this function | v | | + v on this smart contract | +--------------------+ | | + +----------+ with these arguments | | Are there enough |----No----+ + | Executor |--------------------------->| | stamps | | + +----------+ | +--------------------+ | + ^ | | | + | | v | + | | +--------------------+ | + | | | Execute | | + | | +--------------------+ | + | +--------------------------+ + | | + | | + | +------------------------+ | + +----| Results of Execution |<-----------------+ + +------------------------+ +``` The executor attempts to execute a function on the smart contract. If it fails due to Python errors or invalid inputs, the executor will get a response. Otherwise, the function is called and the results of the execution are returned to the executor and which can be passed to the operator. diff --git a/src/smart-contracts/context.md b/src/smart-contracts/context.md index 6ae4059..6a126fc 100644 --- a/src/smart-contracts/context.md +++ b/src/smart-contracts/context.md @@ -54,6 +54,24 @@ def call_direct(): - However, if `2fadab39` calls `call_direct` on the `con_indirect` contract, `con_indirect` will be returned because `con_indirect` is now the caller of this function. ::: + +```txt + con_direct + ctx.signer +----------------+ + | calling | + 2fadab39 ---> | who_am_I( ) | + | | + +----------------+ + ctx.caller = 2fadab39 + + con_indirect con_direct + ctx.signer +---------------+ +----------------+ + | | | calling | + 2fadab39 ---> | | ---> | who_am_I( ) | + | | | | + +---------------+ +----------------+ + ctx.caller = con_indirect +``` A good example of how to use this would be in a token contract. :::tip `con_token` smart-contract diff --git a/src/tools/xian-wallet-utils.md b/src/tools/xian-wallet-utils.md index 0168bbe..6eb541a 100644 --- a/src/tools/xian-wallet-utils.md +++ b/src/tools/xian-wallet-utils.md @@ -91,3 +91,17 @@ XianWalletUtils.sendTransaction( } }); ``` + +### Sign Message + +To request a wallet to sign a message, you can use the `signMessage` function. This function returns a promise that resolves with the signed msg. (only works with strings, JSON, objects wont work) + +```javascript +XianWalletUtils.signMessage("message") + .then(response => { + console.log('Signed Message', response.signature); + }) + .catch(error => { + console.error(error); + }); +```