Can you tell me how to use InvokeScriptTransaction

This is an example of the WAVES IDE.
Please tell me how to use InvokeScriptTransaction to execute ‘func divideAmount ()’.

# waves IDE example
let Alice = Address(base58'3NBVqYXrapgJP9atQccdBPAgJPwHDKkh6A8')
let Bob = Address(base58'3N78bNBYhT6pt6nugc6ay1uW1nLEfnRWkJd')

func divideAmount() = {

    let transferAmount = wavesBalance(this) / 2

                ScriptTransfer(Alice, transferAmount, unit),
                ScriptTransfer(Bob, transferAmount, unit)

I set a script for my account on the test net.
However, I do not understand that it calls with InvokeScriptTransaction.
thank you for reading.

If you use IDE you can run in the console. It is also available in the JS library (waves-transactions)

broadcast(invokeScript({contractAddress: {CONTRACT_ADDRESS_HERE}), call:{function:"divideAmount",args:[]}, payment: []}))

Thank you for your answer(:slight_smile:)
I use an IDE. WavesIDE is very easy to use. Thank you for the development.

{CONTRACT_ADDRESS_HERE} This is replaced by my contract address. OK?

Then I ran it on the console.

It was an error…

Am I making a mistake?

Could you send an error message please?

1 Like

Thank you for your answer( :slight_smile: )

Identifier directly after number (1:57)
+SyntaxError: Identifier directly after number (1:57)↵ at t.M.raise (↵ at t.e.readNumber (↵ at t.e.getTokenFromCode (↵ at t.e.readToken (↵ at t.e.nextToken (↵ at (↵ at t.K.parseObj (↵ at t.K.parseExprAtom (↵ at t.K.parseExprSubscripts (↵ at t.K.parseMaybeUnary (

Sorry, I misinformed you, call should look like below:

broadcast(invokeScript({dappAddress: {CONTRACT_ADDRESS_HERE}), call:{function:"divideAmount",args:[]}, payment: []}))

Difference is in the dappAddress instead of contractAddress in the key.

1 Like

Thanks for the answer.
I tried the code.
The result was the same. Am I wrong?

1 Like

Also today you have to use “dApp” instead of “dappAddress” field for the InvokeScript.

1 Like