@rocketchain/nftchain-package
v0.1.3-RC-1
Published
NFT Chanin package developed by the awesome, fabulous, splendid and fantastic Rocketchain dev team.
Downloads
1
Readme
NFT Chain package
Paquete NPM para utilizar las funciones del smartcontract SHOP y comunicarse con la blockchain, hacer transferencias, consultar saldos y mucho más. Todas las funciones listadas requieren de la firma del usuario (terceros) via metamask.
Requisitos:
- Metamask.
Funciones disponibles:
- setSmartContractAddress
- metamaskConnect
- addBalance
- removeBalance
- removeTotalBalance
- getBalance
- transferFromTo
setSmartContractAddress({smart_contract_address})
Función para configurar la dirección que se tomará del contrato para utilizar en todas las demás funcionalidades.
Parámetros:
[String] [ethereum valid address] smart_contract_address
Respuesta:
-
metamaskConnect()
Funcion para conectarse a metamask via web3 haciendo un llamado a la extension del navegador.
Parámetros:
-
Respuesta:
jsonObject { ok: [boolean] true, message: [string] "Connected successfully.", account: [string] "{ethereum account}" };
addBalance({amount_to_add})
Función para que el usuario pueda añadir balance al contrato y de esa forma poder realizar las acciones de transfer, removeBalance o removeTotalBalance. Los valores a añadir son expresados en MATIC.
Parámetros:
{[integer][matic] amount_to_add}
Respuesta:
jsonObject {ok: [boolean] true, message: [string] 'Balance added', response: [jsonObject] "blockHash":"0xbe00ed296c749fc21b206aeaa9d3c03541b7037a1a8492084ad85ca6052b1566","blockNumber":25435486,"contractAddress":null,"cumulativeGasUsed":2807987,"effectiveGasPrice":2500000008,"from":"0xe4513a7bcd98de50fe7984c82daf5611beba7170","gasUsed":26583,"logsBloom":"0x00000000000000000000000000000000000000000000000000000000010000000000000010000000000000100000000000008000000000000000000000000000000000000000000000000000000000800000000000008000000100000000004000000000000000000000000000000000000000000000000080000000000000000000000000000100000000004000000000000800000080000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000800000108040000000000000000000000000000000000000000000000000000000000000000000100000","status":true,"to":"0xbf8df481ff32431c39fca0fc73c3120a516452d9","transactionHash":"0x1aeefbcace02f64c8996c9313483168952a2630feae7513ba5acd9d059ebada1","transactionIndex":20,"type":"0x2","events":{"0":{"address":"0x0000000000000000000000000000000000001010","blockNumber":25435486,"transactionHash":"0x1aeefbcace02f64c8996c9313483168952a2630feae7513ba5acd9d059ebada1","transactionIndex":20,"blockHash":"0xbe00ed296c749fc21b206aeaa9d3c03541b7037a1a8492084ad85ca6052b1566","logIndex":47,"removed":false,"id":"log_c29dd5d8","returnValues":{},"signature":null,"raw":{"data":"0x0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000036330977876963650000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000285252c3e00563650000000000000000000000000000000000000000000000001bc16d674ec80000","topics":["0xe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c4","0x0000000000000000000000000000000000000000000000000000000000001010","0x000000000000000000000000e4513a7bcd98de50fe7984c82daf5611beba7170","0x000000000000000000000000bf8df481ff32431c39fca0fc73c3120a516452d9"]}},"1":{"address":"0x0000000000000000000000000000000000001010","blockNumber":25435486,"transactionHash":"0x1aeefbcace02f64c8996c9313483168952a2630feae7513ba5acd9d059ebada1","transactionIndex":20,"blockHash":"0xbe00ed296c749fc21b206aeaa9d3c03541b7037a1a8492084ad85ca6052b1566","logIndex":48,"removed":false,"id":"log_b04d4b6b","returnValues":{},"signature":null,"raw":{"data":"0x00000000000000000000000000000000000000000000000000003c7157ae1f00000000000000000000000000000000000000000000000000363364214071f37500000000000000000000000000000000000000000000090fc01218bc23e672f5000000000000000000000000000000000000000000000000363327afe8c3d47500000000000000000000000000000000000000000000090fc012552d7b9491f5","topics":["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63","0x0000000000000000000000000000000000000000000000000000000000001010","0x000000000000000000000000e4513a7bcd98de50fe7984c82daf5611beba7170","0x000000000000000000000000be188d6641e8b680743a4815dfa0f6208038960f"]}}}}
removeBalance({amount_to_remove})
Función para retirar un monto determinado de MATICS del contrato por parte del usuario.
Parámetros:
{[integer][matic] amount_to_remove}
Respuesta:
jsonObject {ok: [boolean] true, message: [string] 'Balance removed', response: [jsonObject] {"blockHash":"0x9aae002c0d99ac627339100c002683469f7f9f79709902d9998a497e90915b8e","blockNumber":25435542,"contractAddress":null,"cumulativeGasUsed":1521149,"effectiveGasPrice":2500000009,"from":"0xe4513a7bcd98de50fe7984c82daf5611beba7170","gasUsed":34181,"logsBloom":"0x00000000000000000000000000000000000000000000000000000000010000000000000010000000000000100000000000008000000000000000000000000000000000000000000000000000000000800000000000008000000100000000004000000000000000000000000000000000000000000000000080000000000000000000000000000100000000004000000000000800000080000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000800000108040000000000000000000000000000000000000000000000000000000000000000000100000","status":true,"to":"0xbf8df481ff32431c39fca0fc73c3120a516452d9","transactionHash":"0xfe9f21ac2931f7ed02c4a5be902edefad8aec72bea2002b3fad3f2cc97baa172","transactionIndex":9,"type":"0x2","events":{"0":{"address":"0x0000000000000000000000000000000000001010","blockNumber":25435542,"transactionHash":"0xfe9f21ac2931f7ed02c4a5be902edefad8aec72bea2002b3fad3f2cc97baa172","transactionIndex":9,"blockHash":"0x9aae002c0d99ac627339100c002683469f7f9f79709902d9998a497e90915b8e","logIndex":24,"removed":false,"id":"log_e2b24307","returnValues":{},"signature":null,"raw":{"data":"0x0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000002851f4b92fba716a0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000003632ab6cd71e716a","topics":["0xe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c4","0x0000000000000000000000000000000000000000000000000000000000001010","0x000000000000000000000000bf8df481ff32431c39fca0fc73c3120a516452d9","0x000000000000000000000000e4513a7bcd98de50fe7984c82daf5611beba7170"]}},"1":{"address":"0x0000000000000000000000000000000000001010","blockNumber":25435542,"transactionHash":"0xfe9f21ac2931f7ed02c4a5be902edefad8aec72bea2002b3fad3f2cc97baa172","transactionIndex":9,"blockHash":"0x9aae002c0d99ac627339100c002683469f7f9f79709902d9998a497e90915b8e","logIndex":25,"removed":false,"id":"log_46e6d95d","returnValues":{},"signature":null,"raw":{"data":"0x00000000000000000000000000000000000000000000000000004db7f5e85d00000000000000000000000000000000000000000000000000285270fc415c95bd00000000000000000000000000000000000000000000090ff077dc635e9bdb47000000000000000000000000000000000000000000000000285223444b7438bd00000000000000000000000000000000000000000000090ff0782a1b54843847","topics":["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63","0x0000000000000000000000000000000000000000000000000000000000001010","0x000000000000000000000000e4513a7bcd98de50fe7984c82daf5611beba7170","0x000000000000000000000000be188d6641e8b680743a4815dfa0f6208038960f"]}}}}}
removeTotalBalance()
Funcioón para retirar el balance total del usuario previamente depositado en el contrato.
Parámetros:
-
Respuesta:
jsonObject {ok: [boolean] true, message: [string] 'Total balance removed', response: [jsonObject] {"blockHash":"0xbde7a9bd99227cc8f4e6ecdbc00455c2e9545a4cc1724590ed3f81e29f6f5a1e","blockNumber":25435588,"contractAddress":null,"cumulativeGasUsed":3762022,"effectiveGasPrice":2500000008,"from":"0xe4513a7bcd98de50fe7984c82daf5611beba7170","gasUsed":28769,"logsBloom":"0x00000000000000020000000000000000000000000000000000000000010000000000000010000000000000100000000000008000000000000000000000000000000000000000000000000000000000800000000000008000000100000000000000000000000000000000000000000000000000000000000080000000000000000000000000000100000000004000000000000800000000000000000000000000200000000000000020000000000000000001000000000000000000000000004000000000000000000001000000000000000000000000800000108000000000000000000000000000000000000000000000000000000000000000000000100000","status":true,"to":"0xbf8df481ff32431c39fca0fc73c3120a516452d9","transactionHash":"0x76896569b81b32b0d666cb216d6962b19f97a1b11babd3c89ce174534a29f3f7","transactionIndex":19,"type":"0x2","events":{"0":{"address":"0x0000000000000000000000000000000000001010","blockNumber":25435588,"transactionHash":"0x76896569b81b32b0d666cb216d6962b19f97a1b11babd3c89ce174534a29f3f7","transactionIndex":19,"blockHash":"0xbde7a9bd99227cc8f4e6ecdbc00455c2e9545a4cc1724590ed3f81e29f6f5a1e","logIndex":83,"removed":false,"id":"log_5c0c7227","returnValues":{},"signature":null,"raw":{"data":"0x0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000036325fcb39db3ae800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004413167ee13f3ae8","topics":["0xe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c4","0x0000000000000000000000000000000000000000000000000000000000001010","0x000000000000000000000000bf8df481ff32431c39fca0fc73c3120a516452d9","0x000000000000000000000000e4513a7bcd98de50fe7984c82daf5611beba7170"]}},"1":{"address":"0x0000000000000000000000000000000000001010","blockNumber":25435588,"transactionHash":"0x76896569b81b32b0d666cb216d6962b19f97a1b11babd3c89ce174534a29f3f7","transactionIndex":19,"blockHash":"0xbde7a9bd99227cc8f4e6ecdbc00455c2e9545a4cc1724590ed3f81e29f6f5a1e","logIndex":84,"removed":false,"id":"log_1c983bd0","returnValues":{},"signature":null,"raw":{"data":"0x00000000000000000000000000000000000000000000000000004169c31059000000000000000000000000000000000000000000000000003632d9f7f2d38710000000000000000000000000000000000000000000000702e4238e54bc933e4e0000000000000000000000000000000000000000000000003632988e2fc32e10000000000000000000000000000000000000000000000702e423cfbe7fa3974e","topics":["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63","0x0000000000000000000000000000000000000000000000000000000000001010","0x000000000000000000000000e4513a7bcd98de50fe7984c82daf5611beba7170","0x000000000000000000000000c26880a0af2ea0c7e8130e6ec47af756465452e8"]}}}}}
getBalance()
Función para obtener el balance del usuario en MATIC que tiene depositado en el contrato .
Parámetros:
-
Respuesta:
jsonObject {ok: [boolean] true, response: [integer] 10}
transferFromTo({wallet_to_transfer_to, token_id, token_amount})
Función para realizar transferencias los usuarios. Será el usuario emisor quien firme la transacción.
Parámetros:
{[string] [ethereum valid address] wallet_to_transfer_to, [integer]token_id, [integer] token_amount}
Respuesta:
jsonObject {ok: [boolean] true, message: 'Token transferred', response: {"receipt":{"blockHash":"0xe95dfc614584a9a5eaaed7b62076434dc4925ad3cfd07dbb997a2076c9218891","blockNumber":25436278,"contractAddress":null,"cumulativeGasUsed":1069458,"effectiveGasPrice":2500000008,"from":"0xe4513a7bcd98de50fe7984c82daf5611beba7170","gasUsed":97273,"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000008000000100000000004000000000000000000000000000000000000000000000000080000000000000000000000000000100000000004000000000000000000080000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000000000100040000000000000000000000000000000000000000000000000000000000000000000100000","status":false,"to":"0xbf8df481ff32431c39fca0fc73c3120a516452d9","transactionHash":"0x790968773b6153b43582993ad04839b826145f78dfa4b3e78fb7aa058c73a4da","transactionIndex":7,"type":"0x2","events":{"0":{"address":"0x0000000000000000000000000000000000001010","blockNumber":25436278,"transactionHash":"0x790968773b6153b43582993ad04839b826145f78dfa4b3e78fb7aa058c73a4da","transactionIndex":7,"blockHash":"0xe95dfc614584a9a5eaaed7b62076434dc4925ad3cfd07dbb997a2076c9218891","logIndex":20,"removed":false,"id":"log_c4e94856","returnValues":{},"signature":null,"raw":{"data":"0x0000000000000000000000000000000000000000000000000000dd2c5687310000000000000000000000000000000000000000000000000044134f41d723ab0800000000000000000000000000000000000000000000091132121b17a2d278fe00000000000000000000000000000000000000000000000044127215809c7a080000000000000000000000000000000000000000000009113212f843f959a9fe","topics":["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63","0x0000000000000000000000000000000000000000000000000000000000001010","0x000000000000000000000000e4513a7bcd98de50fe7984c82daf5611beba7170","0x000000000000000000000000be188d6641e8b680743a4815dfa0f6208038960f"]}}}}}}