usodeimagem.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. const contratoUsoDeImagemABI = [
  2. {
  3. "constant": true,
  4. "inputs": [],
  5. "name": "nomeEmpresa",
  6. "outputs": [
  7. {
  8. "name": "",
  9. "type": "string"
  10. }
  11. ],
  12. "payable": false,
  13. "stateMutability": "view",
  14. "type": "function"
  15. },
  16. {
  17. "constant": false,
  18. "inputs": [],
  19. "name": "receberPeloUso",
  20. "outputs": [],
  21. "payable": true,
  22. "stateMutability": "payable",
  23. "type": "function"
  24. },
  25. {
  26. "constant": false,
  27. "inputs": [
  28. {
  29. "name": "qualAgente",
  30. "type": "address"
  31. }
  32. ],
  33. "name": "definirAgente",
  34. "outputs": [],
  35. "payable": false,
  36. "stateMutability": "nonpayable",
  37. "type": "function"
  38. },
  39. {
  40. "constant": false,
  41. "inputs": [
  42. {
  43. "name": "qualNomeDaEmpresa",
  44. "type": "string"
  45. }
  46. ],
  47. "name": "definirNomeDaEmpresa",
  48. "outputs": [],
  49. "payable": false,
  50. "stateMutability": "nonpayable",
  51. "type": "function"
  52. },
  53. {
  54. "inputs": [],
  55. "payable": false,
  56. "stateMutability": "nonpayable",
  57. "type": "constructor"
  58. }
  59. ];
  60. var contratoUsoDeImagem = web3.eth.contract(contratoUsoDeImagemABI).at("0x1c37800ff4a782685972f115b1f44c486ea4ad11");
  61. function obtemNomeEmpresa() {
  62. contratoUsoDeImagem.nomeEmpresa({from: contaUsuario, gas: 3000000, value: 0}, function (err, resultado) {
  63. if (err) {
  64. console.log("Erro");
  65. console.error(err);
  66. } else {
  67. console.log("Resultado");
  68. let objStatus = document.getElementById("spanNomeEmpresa");
  69. console.log(resultado);
  70. objStatus.innerText = resultado;
  71. }
  72. });
  73. }