Hello, I’ve successfully created a company identity and imported the key file into concordium node through the concordium client utility (concordium-client account update-keys KEY-FILE.json) and if I try to send a transaction with the client (concordium-client transaction send --receiver xx --amount xx --sender xx) it says that it can’t find the default account. I tried to import it through (concordium-client config account import KEY-FILE.json) and add-keys but it files with:
The command concordium-client account update-keys KEY-FILE.json is not for importing keys, it is for updating existing keys. The command for importing keys is config account import --name xx ....
ok, with the format genesis option it worked, but from what I can see concordium client reads only 1 address… does concordium has subaddresses, how do they work?
There is one account created. You can create up to 25 additional accounts using one identity object.
Each account can have up to 2^24 addresses. There is still one account, with one balance, but you can use different addresses to refer to it, in transactions, etc. That gives you a sub-account structure in a sense.
./concordium-client_4.2.0-0 account show-alias default --alias 1
The requested alias for address XXXX is YYYY
./concordium-client_4.2.0-0 transaction send --receiver ZZZZ --amount 10 --sender YYYY
Error: Key directory for account 'YYYY' not found.
Did you forget to add the account (using 'config account add')?
// The signatures used to sign the transaction must be provided in a structured way,
// so that each signature can be mapped to the credential that signed the transaction.
// In this example we assume the key used was from the credential with index 0, and it
// was the key with index 0.
How does work this? if I add an additional account and I use it for the transaction it becomes index 1?
I haven’t found any function that let me use aliases in nodejs sdk, maybe the sender param in the transaction header accepts the alias “id”?
Furthermore,
I’m trying to sign the transaction using the examples in common, (Create a simple transfer), as:
but the function signTransaction gives this error:
node_modules/buffer/index.js:403
length += list[i].length
^
TypeError: Cannot read properties of undefined (reading 'length')
at Function.concat (/node_modules/buffer/index.js:403:25)
at serializeAccountTransactionHeader (/node_modules/@concordium/common-sdk/lib/serialization.js:54:28)
at getAccountTransactionSignDigest (/node_modules/@concordium/common-sdk/lib/serialization.js:128:30)
at signTransaction (node_modules/@concordium/common-sdk/lib/signHelpers.js:59:72)
at file:///main.js:39:30
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I’m using latest version of both common and node sdks.
Hi, the error you are getting looks like the sender param of the transaction header is not an AccountAddress object, which it needs to be.
The nodejs sdk does have a function getAlias for generating an alias, but it is documented in the common-sdk’s documentation (and node-sdk re-exports it):
This function is to generate an alias by an address…
I don’t know account addresses.
I want to use aliases or get addresses in order to send transaction by using multiple addresses.
You should have an address from the initial account that was created along with your identity.
(and its address should be in the account-keys.json you have generated, as a top level field called “address”. I assume that is were you got the signingKey for buildBasicAccountSigner)
The alias is created based on the address you give it, so you need an address to generate an alias for it.
You also need the address to build the header for simpleTransferAccountTransaction. That might be the reason you got an error when signing, because the sender needs to be “sender: new AccountAddress(XXXX)”, where XXXX is your address.