Transaction
Class to create and sign a transaction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account |
Account
|
Account object to sign this transaction |
required |
gas |
int
|
Gas unit for this transaction |
required |
fee |
coin
|
The fee to pay for this transaction (This can also be added later through the |
None
|
memo |
str
|
Memo |
''
|
chain_id |
str
|
Chain-Id "cosmoshub-4", |
'cosmoshub-4'
|
protobuf |
str
|
Define which protobuf files to use. Cosmos, Evmos and Osmosis are built in and otherwise pass the raw package name (cosmospy-protobuf) |
'cosmos'
|
Source code in mospy/Transaction.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
add_dict_msg(msg_dict, type_url)
Add a message as dictionary to the tx body manually.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg_dict |
dict
|
Transaction dict |
required |
type_url |
str
|
Type url for the transaction |
required |
Source code in mospy/Transaction.py
102 103 104 105 106 107 108 109 110 111 112 |
|
add_msg(tx_type, **kwargs)
Add a pre-defined message to the tx body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tx_type |
str
|
Transaction type to match the transaction with the pre-defined ones |
required |
**kwargs |
Depending on the transaction type |
{}
|
Source code in mospy/Transaction.py
77 78 79 80 81 82 83 84 85 86 87 |
|
add_raw_msg(unpacked_msg, type_url)
Add a message to the tx body manually.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unpacked_msg |
Transaction data |
required | |
type_url |
str
|
Type url for the transaction |
required |
Source code in mospy/Transaction.py
89 90 91 92 93 94 95 96 97 98 99 100 |
|
get_tx_bytes()
Sign the transaction and get the tx bytes which can be used to broadcast the transaction to the network.
To broadcast the transaction through the REST endpoint use the get_tx_bytes_as_string()
method instead
Returns:
Name | Type | Description |
---|---|---|
tx_bytes |
bytes
|
Transaction bytes |
Source code in mospy/Transaction.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
get_tx_bytes_as_string()
Sign the transaction and get the base64 encoded tx bytes which can be used to broadcast the transaction to the network.
Returns:
Name | Type | Description |
---|---|---|
tx_bytes |
str
|
Transaction bytes |
Source code in mospy/Transaction.py
158 159 160 161 162 163 164 165 166 |
|
set_fee(amount, denom='uatom')
Set the fee manually
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amount |
int
|
Amount |
required |
denom |
str
|
Denom |
'uatom'
|
Source code in mospy/Transaction.py
122 123 124 125 126 127 128 129 130 |
|
set_gas(gas)
Update the wanted gas for the transaction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gas |
int
|
Gas |
required |
Source code in mospy/Transaction.py
132 133 134 135 136 137 138 139 |
|