Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/lib/explorer/transaction.ex

27 lines
653 B

defmodule Explorer.Transaction do
@moduledoc false
use Ecto.Schema
import Ecto.Changeset
alias Explorer.Transaction
@timestamps_opts [type: Timex.Ecto.DateTime,
autogenerate: {Timex.Ecto.DateTime, :autogenerate, []}]
schema "transactions" do
field :hash, :string
timestamps()
belongs_to :block, Explorer.Block
end
@doc false
def changeset(%Transaction{} = block, attrs) do
block
|> cast(attrs, [:block_id, :hash])
|> validate_required([:block_id, :hash])
|> foreign_key_constraint(:block_id)
|> update_change(:hash, &String.downcase/1)
|> unique_constraint(:hash)
end
end