Closed davidlee-crastonic closed 2 years ago
The example was wrong in the doc, it should be connex.vendor.sign(...).signer(...).gas(...).link(...).comment(...).request().then
, I will update the doc ASAP.
Thank you very much
And the mechanism to sign transaction is not so clear in the doc. For example, how to customize transferABI aand transferMethod in the doc const transferABI = {"constant":false,"inputs":[{"name":"_to","type":"address"},
{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}
const transferMethod = connex.thor.account('0x0000000000000000000000000000456E65726779').method(transferABI)
// Connex author's address and amount in wei
const energyClause = transferMethod.asClause('0xd3ae78222beadb038203be21ed5ce7c9b1bff602', '1000000000000000000000')
connex.vendor.sign('tx', [
{
to: '0xd3ae78222beadb038203be21ed5ce7c9b1bff602',
value: '100000000000000000000',
data: '0x',
comment: 'Transfer 100 VET'
},
{
comment: 'Transfer 1000 VeThor',
...energyClause
}
])
Then how is the private key used for signing? Isn't it neccessary?
ABI is given by the solidity compiler.
Private key management is done by simple wallet
from connex-driver in your environment
got it But the document for creating and sending transaction is not changed yet. When will it be ready for use?
Or could you please leave here some simple instruction how to create and sign transfer?
Doc is updated, for your case add .request()
before .then
.
ok, I will try it.
Would you please tell me what is the address in this part?
const transferMethod = connex.thor.account('0x0000000000000000000000000000456E65726779').method(transferABI)
https://docs.vechain.org/connex/api.html#account-visitor, documented here the address in account(address)
is the contract's address, here I used VTHO
contract for example.
So you mean if I want to transfer VET, I have to use another address?
No, transfer VET just needs add a clause {to: <address>, value: <value>}
connex.vendor.sign('tx', [
{
to: '0xd3ae78222beadb038203be21ed5ce7c9b1bff602',
value: '100000000000000000000',
data: '0x',
comment: 'Transfer 100 VET'
}
])
Thanks Then How can I export private key from Sync2 wallet? I can not find it anywhere
Sync2 does not support exporting the private key, but you can do it with thor-devkit with your mnemonic words.
Thank you very much.
I am now using connex to sign transfer with node.js, but it fails with following error.
I just followed this instruction: #https://docs.vechain.org/connex/api.html#transaction-signing-service Hope to know how to proceed in this case.