# List as Argument of Callable Function
# Prerequisites
- The dApp script uses Standard library version 4 or higher.
- List elements are of one of the following types:
Nested lists are not allowed as arguments to a callable function (unlike function without annotation).
# Ride Code
The list argument is specified as follows:
arg_name: List[elem_type]
Example script:
{-# STDLIB_VERSION 8 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
@Callable(i)
func join(strings: List[String]) = {
[
StringEntry(toBase58String(i.caller.bytes), strings[0] + "_" + strings[1] + "_" + strings[2])
]
}
# Script invocation
You can create and send an Invoke Script transaction using client libraries.
# JavaScript
const { invokeScript, broadcast } = require('@waves/waves-transactions');
// Testnet node
// For Mainnet, use defalut
const nodeUrl = 'https://nodes-testnet.wavesnodes.com';
const seed = 'insert your seed here';
// Invocation parameters
const invParams = {
dApp: "3MyptFjRHW4CTPNQKdF8mu3izsZEPEdzm8s",
payment: [],
call: {
function: 'join',
args: [
{
type: 'list',
value: [
{ type: 'string', value: 'alpha' },
{ type: 'string', value: 'beta' },
{ type: 'string', value: 'gamma' }
]
}
]
},
chainId: 'T' // For Mainnet, set 'W' or omit
};
// Create and sign Invoke Script transaction
const invokeTx = invokeScript(invParams, seed);
broadcast(invokeTx,nodeUrl).then(resp => console.log(resp));
console.log('Tx ID: ' + invokeTx.id);
💡 Use Signer to invoke your script on behalf a range of users.
# Python
import pywaves as pw
// Testnet node; omit for Mainnet
pw.setNode('https://nodes-testnet.wavesnodes.com/', chain='testnet')
my_address = pw.Address(seed = 'insert your seed here')
my_address.invokeScript(
'3MyptFjRHW4CTPNQKdF8mu3izsZEPEdzm8s',
'join',
[{"type": "list", "value": [
{ "type": "string", "value": "alpha" },
{ "type": "string", "value": "beta" },
{ "type": "string", "value": "gamma" }
]}], [])