Closed robvanmieghem closed 5 years ago
- how do we obtain blockid & txid for Coin Creation Transaction? user input?
The coin creation transaction is created by the bridge, a wallet only needs to be able to understand it to take the coinoutputs in to account to be able to spend them.
- where can we get currently registered addresses
This feature is still in development.
- is 'pubkey' on address registration transaction always equal to the 'publickey' used in the coininput, in our case?
yes
(EDIT: it can be, but it doesn't have to be, just has to a valid public key you own and want to use, and also sign the Tx with for the given root signature property. But I guess in your case where you only ever use 1 address and thus 1 public key, it would be the same one yes)
- how to properly decode transactions using the rivine library (to set publickey). Like, how to convert/cast a regular 'Transaction' type to ERC20AddressRegistrationTransaction
The go datastructures are linked from the erc20.md
The ERC20AddressRegistrationTransaction
and the ERC20ConvertTransaction
structures implement json.Unmarshaler.UnmarshalJSON
and MarshalJSON
so normal json marshalling can be used or you can create them directly
EDIT: see answer below for more info
- how to create 'signature' on ERC20 Address Registration Transaction (SignatureHash without param?)
~yes~ EDIT: no, see answer below
- 'value' on refundcoinoutput for Address Registration Transaction -> 0? or is it just ignored
This the same as when sending 5tft in a regular transaction but your inputs sum up to say 100, you also add an output of 95 to your own address then.
EDIT: see answer below for more info
how to properly decode transactions using the rivine library (to set publickey). Like, how to convert/cast a regular 'Transaction' type to ERC20AddressRegistrationTransaction
It is unclear what you mean by what a regular 'Transaction' is supposed to mean or in what context this is used. JSON-decoding a transaction is always done using the Transaction's UnmarshalJSON method, implemented at https://godoc.org/github.com/threefoldtech/rivine/types#Transaction.UnmarshalJSON.
In order to convert a generic Transaction into its correct type, you either check its version first, or if you're sure it is the version you think it is, than you can of course skip this. Either way, you would use the correct constructor function. In order to turn a generic Transaction
type into the ERC20AddressRegistrationTransaction
you would use the ERC20AddressRegistrationTransactionFromTransaction
(constructor) function (found in the github.com/threefoldfoundation/tfchain/pkg/types
Go package). It will return an error in case the Transaction was invalid (or wasn't a ERC20AddressRegistrationTransaction
).
how to create 'signature' on ERC20 Address Registration Transaction (SignatureHash without param?)
Now sure what you mean with params, but I'm going to assume that you mean extraObjects
. And I'm going to assume you are calling (github.com/threefoldtech/rivine/types.Transaction) SignatureHash
, in which case you'll have to give it the github.com/threefoldfoundation/tfchain/pkg/types.ERC20AdddressRegistrationSignatureSpecifier
specifier for signing, as the only extraObject
, thus as in:
import (
// ...
rtypes "github.com/threefoldtech/rivine/types"
tftypes "github.com/threefoldfoundation/tfchain/pkg/types"
// ...
)
// ...
var tx rtypes.Transaction
hash, err := tx.SignatureHash(tftypes. types.ERC20AdddressRegistrationSignatureSpecifier)
// ...
'value' on refundcoinoutput for Address Registration Transaction -> 0? or is it just ignored
0
as a value is not allowed. If you do not need any refund coin output (which is very unlikely), you can keep it as nil
if you are building it up in Go. In JSON-encoded form you can just omit that refundcoinoutput
property if not used.
@lucasvanhalst, what do you mean with "where can we get currently registered addresses", what are you trying to get specifically, and why?
I meant the addresses registered as withdrawal address, but I suppose I can just list all transactions for a given address and check if any of them their version is 210(ERC20AddressRegistration), or is that not correct?
but I suppose I can just list all transactions for a given address and check if any of them their version is 210(ERC20AddressRegistration), or is that not correct?
Would be logical enough, but sadly that is not so. It will only return transactions that reference the address in a coin/blockstake input/output.
If all you care about is whether or not it is registered and part of a block, than what you could do is look for the ERC20 address (using the same endpoint as the one you use to look up a regular TFT address). If it returns you a reply, it means it is registered and part of a block. You would not know how much confirmations it has though. But it would for sure has 1 confirmation (as it would mean it is part of a created block).
but I suppose I can just list all transactions for a given address and check if any of them their version is 210(ERC20AddressRegistration), or is that not correct?
Please pull latest of the bridge_tft_erc20
branch @lucasvanhalst, code has been pushed that should help you with this. Here is some info for you, as to know the "status" of an ERC20 address you care about:
Apps can now compute such a status very easily by looking up the ERC20 address using the regular >
/explorer/hashes/:hash
endpoint:
- If an error is and/or no reply is returned, than the ERC20 can be seen as
unregistered
;- If a reply is returned than the
confirmations
child property from theerc20info
root property has > to be checked:
- if it is
0
, than the status can be seen asunconfirmed
(still in Tx pool)- Otherwise the value is
>=1
:
1
being just created, and thus the highest block is the block in which the address is created- Should the App want, it can thus define a more refined status by checking this confirmations value against an arbitrary value (e.g.
6
) to differentiate for example betweenconfirming
andconfirmed
;
EDIT: the ERC20AddressRegistration
Transaction will now also be returned when looking up the ERC20 address or related TFT address, but as I just explained, there is probably not much reason for you to care about that.
I've tried to create an address registration transaction on the testnet, but got the error {"message":"error decoding the supplied transaction: unknown transaction type"}
this was the data sent as payload to POST https://explorer2.testnet.threefoldtoken.com/transactionpool/transactions
{
"version": 210,
"data": {
"pubkey": "ed25519:3127ae22f3d40743c48517b5321fa36f1452499e51e6319bbdee35b52439a6ee",
"tftaddress": "01312bca26747afc3744e04e6c2cbe5aa7818e962d2cbd354cdad935cd6c49122b9f35eebf5f99",
"erc20address": "0x48f8ab265d3e472d09da04293b28b03a7e7c3a3f",
"signature": "989b3b3ff380f1d9e1a27e689a40f952b45cedc08b8ed8ff9ebc1d8a2d013d561fa91d7d50ab45352e27c292bf769f13991f32d9ff455a698b417900f5887f04",
"regfee": "10000000000",
"txfee": "100000000",
"coininputs": [
{
"parentid": "e8824cc1b07f6ebb8df8f44e2b33e50bdfbbd211ab4a14cc902bc00c3e2a3d8e",
"fulfillment": {
"type": 1,
"data": {
"publickey": "ed25519:3127ae22f3d40743c48517b5321fa36f1452499e51e6319bbdee35b52439a6ee",
"signature": "b1ea5a3d8ee3504dd28b2a44c8270331450aee312ef6585deadcbd97263cd04cbecdc6d19cc0958740b9be189c37f015ef77877dbed863e452c99b646842f904"
}
}
}
],
"refundcoinoutput": {
"value": "410000000",
"condition": {
"type": 1,
"data": {
"unlockhash": "01312bca26747afc3744e04e6c2cbe5aa7818e962d2cbd354cdad935cd6c49122b9f35eebf5f99"
}
}
}
}
}
I thought the testnet already supported this, am I wrong?
this was the data sent as payload to POST https://explorer2.testnet.threefoldtoken.com/transactionpool/transactions
https://explorer.testnet.threefoldtoken.com/transactionpool/transactions
testnet explorer seems to be down, and when trying to set up local explorer it gives me this:
lucas:~/golang/src/github.com/threefoldfoundation/tfchain$ tfchaind -M cgte --network=testnet
Loading...
Binding API Address and serving the API...
Loading (auto) transaction db (0/4)...
Context is done, quitting...
context is done, quitting...
daemon failed failed to create network config: failed to open the transaction DB: error opening tfchain transaction database with unknown version: incompatible version
I'd rather not sync from scratch since that takes a day.. any suggestions?
Explorer is back up now
Looks like it's down again
yeah up again in the meantime
Seems like the testnet is stuck at the moment at block 189,647 due to lack of miners
Testnet is making blocks again
It looks like the erc20 bridge isn't working correctly, rob is looking into it. see https://ropsten.etherscan.io/tx/0x11eb339ce2523a6f2bd64bc08079ab5c2d3e426af9d733d7a311ae7c820789f2
bridge has been fixed. Transactions are processed correctly now
Can be closed, or is there still ongoing work @robvanmieghem? When can we test the App in staging by the way?
@lucasvanhalst can you paste your questions here?