Java Code Examples for org.ethereum.util.Utils#addressStringToBytes()
The following examples show how to use
org.ethereum.util.Utils#addressStringToBytes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContractCallDialog.java From ethereumj with MIT License | 6 votes |
private void playContractCall() { byte[] addr = Utils.addressStringToBytes(contractAddrInput.getText()); if(addr == null) { alertStatusMsg("Not a valid contract address"); return; } ContractDetails contractDetails = UIEthereumManager.ethereum .getRepository().getContractDetails(addr); if (contractDetails == null) { alertStatusMsg("No contract for that address"); return; } final byte[] programCode = contractDetails.getCode(); if (programCode == null || programCode.length == 0) { alertStatusMsg("Such account exist but no code in the db"); return; } Transaction tx = createTransaction(); if (tx == null) return; Block lastBlock = UIEthereumManager.ethereum.getBlockchain().getLastBlock(); ProgramPlayDialog.createAndShowGUI(programCode, tx, lastBlock); }
Example 2
Source File: ContractCallDialog.java From ethereumj with MIT License | 4 votes |
private void populateContractDetails() { byte[] addr = Utils.addressStringToBytes(contractAddrInput.getText()); if(addr == null) { alertStatusMsg("Not a valid contract address"); return; } ContractDetails contractDetails = UIEthereumManager.ethereum .getRepository().getContractDetails(addr); if (contractDetails == null) { alertStatusMsg("No contract for that address"); return; } final byte[] programCode = contractDetails.getCode(); if (programCode == null || programCode.length == 0) { alertStatusMsg("Such account exist but no code in the db"); return; } final Map storageMap = contractDetails.getStorage(); contractDataInput.setBounds(70, 80, 350, 145); contractDataInput.setViewportView(msgDataTA); URL expandIconURL = ClassLoader.getSystemResource("buttons/add-23x23.png"); ImageIcon expandIcon = new ImageIcon(expandIconURL); final JLabel expandLabel = new JLabel(expandIcon); expandLabel.setToolTipText("Cancel"); expandLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); expandLabel.setBounds(235, 232, 23, 23); this.getContentPane().add(expandLabel); expandLabel.setVisible(true); final Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); final JPanel detailPanel = new JPanel(); detailPanel.setBorder(border); detailPanel.setBounds(135, 242, 230, 2); final JPanel spacer = new JPanel(); spacer.setForeground(Color.white); spacer.setBackground(Color.white); spacer.setBorder(null); spacer.setBounds(225, 232, 40, 20); this.getContentPane().add(spacer); this.getContentPane().add(detailPanel); expandLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ContractCallDialog.this.setSize(500, 530); ContractCallDialog.this.creatorAddressCombo.setBounds(70, 367, 230, 36); ContractCallDialog.this.gasInput.setBounds(330, 360, 90, 45); ContractCallDialog.this.rejectLabel.setBounds(260, 425, 45, 45); ContractCallDialog.this.approveLabel.setBounds(200, 425, 45, 45); ContractCallDialog.this.statusMsg.setBounds(50, 460, 400, 50); spacer.setVisible(false); expandLabel.setVisible(false); detailPanel.setVisible(false); JTextField contractCode = new JTextField(15); contractCode.setText(Hex.toHexString( programCode )); GUIUtils.addStyle(contractCode, "Code: "); contractCode.setBounds(70, 230, 350, 45); JTable storage = new JTable(2, 2); storage.setTableHeader(null); storage.setShowGrid(false); storage.setIntercellSpacing(new Dimension(15, 0)); storage.setCellSelectionEnabled(false); GUIUtils.addStyle(storage); JTableStorageModel tableModel = new JTableStorageModel(storageMap); storage.setModel(tableModel); JScrollPane scrollPane = new JScrollPane(storage); scrollPane.setBorder(null); scrollPane.getViewport().setBackground(Color.WHITE); scrollPane.setBounds(70, 290, 350, 50); ContractCallDialog.this.getContentPane().add(contractCode); ContractCallDialog.this.getContentPane().add(scrollPane); } }); this.repaint(); }