Closed songsongMr closed 6 years ago
what the Application scenarios of the sign of eosjs-ecc .
Using an account to initiate a request to eos,, it seems that eos is just to check whether his private key is in keyProvider, if in the request is successful. What is the use of signatures in ecc?
Signatures are used anytime your writing data to the blockchain.. Reading data is public and does not need any private key or signature.
I'm not sure if my understanding of the signature is correct.I hope to get your advice. Could you show me an example . Thank you so much!
eos.transaction({
actions: [
{
account: 'tester',
name: 'reguser',
authorization: [{
actor: 'tester',
permission: 'active'
}], //Is this the signature? it will get the key from keyProvider. if the key is in keyProvider, the process of signature is complete.I'm not sure if my understanding of the signature is correct.I hope to get your advice.
data: {
name: "test",
wname: "w123",
password: "12345",
memo:"call reguser"
}
}
]
})
Is there a reason your using eos.transaction? Can you instead pull the contract and call reguser directly?
Never put a password in a transaction like this.. It will be instantly seen by the entire network.. You'll probably need to change this to use public key private key security..
eos.contract('tester').then(tester => {
tester.reguser({
name: "test",
wname: "w123",
memo:"call reguser"
})
}, {authorization: 'tester'})
would you please show how to work with private key offline with eosjs-ecc? Thanks.
Anywhere you see wif
in the README that is working with a private key in the API .. Do you have a more specific question?
All method calls are "offline" .. there are no network API requests in this package.
@jcalfee Hi, One of the action in my smart contract require multiple permission(from user and admin). Can you suggest me the way to get the transaction signed by the user, receive it and sign it by admin and finally push to the blockchain?
All offline? Create eosjs like this and tr will contain the signature. Do this in both environments. Make sure your transaction headers have extended the expiration time well beyond 1 minute.
let key
eos = Eos({httpEndpoint: null, keyProvider: () => key})
key = wif1
await tr = eos.transaction(transaction)
Or online:
let key
eos = Eos({broadcast: false, expireInSeconds: 60 * 1024, keyProvider: () => key})
key = wif2
await tr = eos.transaction(transaction)
Print out tr
and make sure you collect and combine signatures.. Send the transaction to eos.pushTransaction
when your done..
@jcalfee ,Hi, jcalfee
I am writing a nodejs web page to send transaction to the blockchain. My keyprovider setting is shown below: my keyprovider looks like this: keyProvider:[[ "EOS5BtL6cQsVzMhuujppUTKmVWFY6EYLrDfdraaQnA2BBJYCrxCCb", "5KCk5d5pAuack1NiqSxTiJsrAiE6wgLxYHGo6JACpMuFJb39NeG" ],[ "EOS5GQ7PHBvEPCRWhiA3rNDVrrLYtvoxh7Vvnska9xa4RjkyZvUbH", "5J38vcyy1CVR9NeAArrZfeAUzjyGEAzJZmJ7paLHqJYKQo6hQC9" ],[ "EOS5cDrz8eHLHwW94QSpSwwLFphUCRKYiCyoZ8CoySm6EVMwHCDBE", "5Jjvnup2dqUGsQ7KhvJgYyohL8jUv9zcWcECHiWyZuALxXZWT5C" ],[ "EOS5sGH7Rdch9qHaXLA98NRg1qPrH7UobrZBsdS5Nt7Qd2uJVH8G3", "5HvCUxF4AVkePfAewWjXyqiApMQ3Yy6NzGKJE2w8WQvtEGvZLqa" ],[ "EOS6AT4kMkkiYhDgUeJ8YxupBRWHzu9pLPPicqLnpPN7qViT5TFiU", "5J5RHaY31VLcZoFUhjfSudyArKu6WWFbdmocaFYojsehENAFKRQ" ],[ "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" ],[ "EOS8MHfK4v7UGHrYKq1beFbrxv8LegKvgaXk4xEcK1ynBRGDqbAvU", "5KELKQohNbdoJ2MRmHPQh6ef7tFWSpBQ1gCpcjkNKER7hWczwCZ" ] ], // Your private ke
when i click the send transaction button I got this problem: apigen.js:115 AssertionError {name: "AssertionError", actual: false, expected: true, operator: "==", message: "expecting public or private keys from keyProvider", …}
Thank you for your help!
any keyprovider sample is available?
The keyprovider is an array of private keys only .. See the README here: https://github.com/EOSIO/eosjs
@jcalfee ,Thank you! I will read the readme file. Thank you!
@jcalfee , Hello again! I found this in readme file
"keyProvider [array
I wonder how to write the "array
keyProvider = ['5KELKQohNbdoJ2MRmHPQh6ef7tFWSpBQ1gCpcjkNKER7hWczwCZ', '5J38vcyy1CVR9NeAArrZfeAUzjyGEAzJZmJ7paLHqJYKQo6hQC9']
eosjs-ecc is already included in eosjs .. You'll probaby see an example that does what you want in the README..
The only reason why you want eosjs-ecc alone is if you only want to work with private keys offline..