immutability-io / vault-ethereum

A plugin that turns Vault into an Ethereum wallet.
244 stars 66 forks source link

How to pass hex string data to sign-tx #56

Open bojan96 opened 5 years ago

bojan96 commented 5 years ago

When I set "data" property to hex string it seems that hex string is interpreted as utf8 byte array instead of simply setting "data" of ethereum transaction to original hex string. This makes it impossible to encode contract call on client side. This is a MAJOR ISSUE. Any workarounds?

deepchenna commented 5 years ago

+1 I'd like to request for an enhancement to "Add support for smart contract function calls"

Detailed Description

In the Current implementation, sign-tx is expecting data filed to be in UTF8 string format, this is the limitation that blocking sing-tx method to be used for smart contract calls, smart contract calls require hex data to be supported by the data field.

Possible Implementation

Option1: Change existing sing-tx function to accept data in raw hex string. Option2: Add new API for smart contract function calls with hex support

deepchenna commented 5 years ago

Any Update on this issue?

cypherhat commented 5 years ago

Are you asking for a flag that tells the plugin to convert the data field from a string (UTF8) to hexadecimal prior to signing?

Something like this?

vault write ethereum/dev/accounts/rinkeby/sign-tx to="0x36D1F896E55a6577C62FDD6b84fbF74582266700" amount="200000000000000000" data="data encoded as a string" encoding="hex" send=false

This means that the incoming data has to be rendered as a UTF8 string first.

deepchenna commented 5 years ago

Are you asking for a flag that tells the plugin to convert the data field from a string (UTF8) to hexadecimal prior to signing?

Something like this?

vault write ethereum/dev/accounts/rinkeby/sign-tx to="0x36D1F896E55a6577C62FDD6b84fbF74582266700" amount="200000000000000000" data="data encoded as a string" encoding="hex" send=false

This means that the incoming data has to be rendered as a UTF8 string first.

The problem is with providing the data payload as UTF8 string, The data payload can be a smart contract function call, and UTF8 character set will cover all hexadecimal values possible.

I'd want it to support like this.

vault write ethereum/dev/accounts/rinkeby/sign-tx to="0x36D1F896E55a6577C62FDD6b84fbF74582266700" amount="200000000000000000" data="0xd3c9cc2600000000000000000000000000000000000000000000000000000000000003e8" encoding="hex" send=false

cypherhat commented 5 years ago

I chose a different approach. Please advise if this is acceptable. If so, I will close this issue. This approach allows you to sign arbitrary binary data - with the limitation that you supply the data in a file.

$ vault write ethereum/dev/accounts/rinkeby/sign-tx \
to="0x36D1F896E55a6577C62FDD6b84fbF74582266700" \
amount="200000000000000000" \
data="/Volumes/ext/go/src/github.com/immutability-io/vault-ethereum/scripts/transaction.data" \
dataIsFile=true \
send=false
deepchenna commented 5 years ago

I chose a different approach. Please advise if this is acceptable. If so, I will close this issue. This approach allows you to sign arbitrary binary data - with the limitation that you supply the data in a file.

$ vault write ethereum/dev/accounts/rinkeby/sign-tx \
to="0x36D1F896E55a6577C62FDD6b84fbF74582266700" \
amount="200000000000000000" \
data="/Volumes/ext/go/src/github.com/immutability-io/vault-ethereum/scripts/transaction.data" \
dataIsFile=true \
send=false

Is this expects the file to be sitting in the machine where the vault is running?

The data payload is generated dynamically in the DApp on the client side, this approach of the file will not work in our scenario.

cypherhat commented 5 years ago

Release of encoding.

Note: In the case of hex encoding, the data should NOT be prefixed with 0x.